在编辑我的 Repository 类时弹出一个错误
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;
我在
遇到异常.SelectMany(c => c.APPLICANTs) //this line added
说:
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
最佳答案
SelectMany 接受一个对象集合,其中每个对象都有一个集合属性。
您在第一条语句中选择了 APPLICANTs 集合并在其上运行 SelectMany 似乎没有意义。
查看这些链接以更好地了解 SelectMany。
http://msdn.microsoft.com/en-us/library/bb534336.aspx
Difference Between Select and SelectMany
关于c# - 方法 'System.Linq.Queryable.SelectMany System.Linq.IQueryable 的类型参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16644135/