Hello
I have 3 tables in my testdatabase, Customers <-> CustomersUsergroups <-> Usergroups
For customers I have a method that returns all Usergroups like this:
public IQueryable<Usergroup> GetUsergroups()
{
return from ug in _entities.UsergroupSet.Include("Customer")
select ug;
}
And to that I have a "filter-class" for class Usergroup
public static IQueryable<Usergroup> ByUsergroupID(this IQueryable<Usergroup> qry, int usergroupID)
{
return from ug in qry
where ug.UsergroupID == usergroupID
select ug;
}
so when I type:
return _repository.GetUsergroups().ByUsergroupID(usergroupID);
it works great, but the problem now is that I would like to extend so I can filter by CustomerID aswell, sort of like:
public static IQueryable<Customer> ByCustomerID(this IQueryable<Customer> qry, int customerID)
{
return from c in qry
where c.CustomerID == customerID
select c;
}
so I can use it like:
return _repository.GetUsergroups().ByCustomerID(customerID);
is that possible to do with just using "Include"? or isnt it an easy way to fix that since they are different classes?
Thanks in advance
/M