[英]Entity Framework Include Issue
I am currently working on a Customer Repository and I came across this issue of the include functionality not working. 我目前正在开发一个客户存储库,并且遇到了包含功能无法正常工作的问题。 I was hoping that someone might be able to shed some light on why this isn't working and maybe give some feedback on how to implement this better.
我希望有人能够阐明为什么这种方法不起作用,并可能就如何更好地实现这一点提供一些反馈。
public IQueryable<Domain.Customers.Customer> GetCustomers(params Expression<Func<Domain.Customers.Customer, object>>[] include)
{
IQueryable<Domain.Customers.Customer> query = _context.Customers.AsNoTracking();
foreach (var property in include)
{
query.Include(property);
}
return query;
}
A call to this function looks like this 对该函数的调用如下所示
var customer = _customerRepository.GetCustomers(p=>p.Category);
Any help would be greatly appreciated. 任何帮助将不胜感激。
All LINQ statements return new IQueryable<T>
/ IEnumerable<T>
instances. 所有LINQ语句都返回新的
IQueryable<T>
/ IEnumerable<T>
实例。 You have to keep the latest modification: 您必须保留最新的修改:
query = query.Include(property);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.