Linq filtering an IQueryable<T> (System.Data.Linq.DataQuery) object by a List<T> (System.Collection.

Posted by Klaptrap on Stack Overflow See other posts from Stack Overflow or by Klaptrap
Published on 2010-04-19T08:21:35Z Indexed on 2010/04/19 8:23 UTC
Read the original article Hit count: 715

Filed under:
|
|
|
|

My IQueryable line is:

 // find all timesheets for this period - from db so System.Data.Linq.DataQuery
 var timesheets = _timesheetRepository.FindByPeriod(dte1, dte2);

My List line is:

 // get my team from AD - from active directory so System.Collection.Generic.List
 var adUsers = _adUserRepository.GetMyTeam(User.Identity.Name);

I wish to only show timesheets for those users in the timesheet collection that are present in the user collection.

If I use a standard c# expression such as:

 var teamsheets = from t in timesheets
                  join user in adUsers on t.User1.username equals user.fullname
                  select t;

I get the error "An IQueryable that returns a self-referencing Constant expression is not supported"

Any recommendations?

© Stack Overflow or respective owner

Related posts about c#

Related posts about asp.net-mvc