Multiple Includes() in EF Core

后端 未结 8 2173
傲寒
傲寒 2020-12-08 08:07

I have an extension method that lets you generically include data in EF:

public static IQueryable IncludeMultiple(this IQueryable          


        
8条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-08 08:36

    public Task> GetAll()
        {
            var query = _Db.Set().AsQueryable();
            foreach (var property in _Db.Model.FindEntityType(typeof(TEntity)).GetNavigations())
                query = query.Include(property.Name);
            return query.ToListAsync();
    
        }
    

提交回复
热议问题