Reputation: 754
While editing my Repository class an Error pops out
var applicantList = (from a in context.Profiles
join app in context.APPLICANTs
on a.PROFILE_ID equals app.Profile_id into joined
from j in joined.DefaultIfEmpty()//.OrderBy(v => v.APPLICANT_ID)
select j //<-- this is APPLICANTs type
).Take(1000);
applicantdata = applicantList
.SelectMany(c => c.APPLICANTs) //this line added
.AsQueryable().OrderBy(v => v.APPLICANT_ID).ToList();
if (applicantdata.Any())
{
Cache.Set("applicants", applicantdata, 30);
}
}
return applicantdata;
Im having an exception at
.SelectMany(c => c.APPLICANTs) //this line added
saying that :
The type arguments for method 'System.Linq.Queryable.SelectMany(System.Linq.IQueryable, System.Linq.Expressions.Expression>>)' cannot be inferred from the usage. Try specifying the type arguments explicitly
Upvotes: 1
Views: 3768
Reputation: 2861
SelectMany is used for 'flattening' a list of lists. You don't have a list of lists here. You have a list of anonymous joined rows.
It's a bit difficult to infer what you're querying for, but if you're looking to get the related rows (the APPLICANTs rows), you can use this:
var applicantList = (from a in context.Profiles
join app in context.APPLICANTs
on a.PROFILE_ID equals app.Profile_id
select app).Take(1000)
Upvotes: 1
Reputation: 14874
SelectMany accepts a collection of object which each of them have a collection property inside.
You selected APPLICANTs collection at the first statement and running a SelectMany on it doesn't seem to be meaningful.
Checkout these links to understand the SelectMany better.
http://msdn.microsoft.com/en-us/library/bb534336.aspx
Difference Between Select and SelectMany
Upvotes: 4