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. You have to keep the latest modification:
query = query.Include(property);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.