-
Notifications
You must be signed in to change notification settings - Fork 382
Closed
Description
Hi!
I have this piece of code
public async Task<T> SingleOrDefault(int id)
{
var query = DbContext.SomeEntity.Where(x => x.Id == id);
return await _mapper.From(query).ProjectToType<T>().SingleOrDefaultAsync();
}it throws the following Exception
Data: System.MissingMethodException: Constructor on type 'Mapster.EFCore.MapsterAsyncEnumerable`1[[SomeSystem.SomeDto, SomeSystem.Api, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' not found.
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture)
at Mapster.EFCore.MapsterQueryableProvider.ExecuteAsync[TResult](Expression expression, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ExecuteAsync[TSource,TResult](MethodInfo operatorMethodInfo, IQueryable`1 source, Expression expression, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ExecuteAsync[TSource,TResult](MethodInfo operatorMethodInfo, IQueryable`1 source, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.SingleOrDefaultAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken) .........
If i exchange the code to the following, it works fine
public async Task<T> SingleOrDefault(int id)
{
var query = DbContext.SomeEntity.Where(x => x.Id == id);
var list = await _mapper.From(query).ProjectToType<T>().ToListAsync();
return list.FirstOrDefault();
}Additional info:
AspNet 7.0
Mapster 7.3.0
Mapster.EFCore 5.1.0
Metadata
Metadata
Assignees
Labels
No labels