Generics 如何在存储库模式中实现SelectMany
我想在通用存储库模式中实现SelectMany查询 我的代码如下所示:Generics 如何在存储库模式中实现SelectMany,generics,select,repository-pattern,Generics,Select,Repository Pattern,我想在通用存储库模式中实现SelectMany查询 我的代码如下所示: var query = ctx.Storehouse.Where(x => x.Id == getId) .SelectMany(x => x.Products).Select(x => new { x.Id, .
var query = ctx.Storehouse.Where(x => x.Id == getId)
.SelectMany(x => x.Products).Select(x => new
{
x.Id,
.
...
}).ToList();
我需要更改以下函数的参数:
public virtual async Task<ICollection<TEntity>> ListOfFoo<TResult>(
Expression<Func<TEntity, bool>> condition01,
Expression<Func<TEntity, TResult>> condition02,
Expression<Func<TEntity, TResult>> condition03)
{
return await Dbset.Where(condition01).SelectMany(condition02).Select(condition03).ToListAsync();
}
并获取如下所示的错误:
用法:
var list = await ListOfFooAsync<User, Category, CustomType1>(
user => user.Id > 1, user => user.Categories, category => new CustomType1
{
Id = category.Id
});
var list = await ListOfFooAsync<User, Category, CustomType1>(
user => user.Id > 1, user => user.Categories, category => new CustomType1
{
Id = category.Id
});