该类型参数的方法“System.Linq.Queryable.SelectMany System.Linq.IQueryable [英] The type arguments for method 'System.Linq.Queryable.SelectMany System.Linq.IQueryable
问题描述
在编辑我的仓库类错误弹出
VAR applicantList =(来自于context.Profiles
加入context.APPLICANTs应用
在a.PROFILE_ID等于app.Profile_id成加盟
从joined.DefaultIfEmpty()Ĵ//排序依据(V => v.APPLICANT_ID)。
选择j可//< - 这是申请者键入
)。取(1000); applicantdata = applicantList
.SelectMany(C => c.APPLICANTs)//这一行加
。.AsQueryable()的OrderBy(V => v.APPLICANT_ID).ToList(); 如果(applicantdata.Any())
{
Cache.Set(申请人,applicantdata,30);
}
}
返回applicantdata;
林具有
异常 .SelectMany(C => c.APPLICANTs)//这一行加
说:
有关方法的类型参数'System.Linq.Queryable.SelectMany(System.Linq.IQueryable,System.Linq.Ex pressions.Ex pression >>)不能从使用推断。请尝试显式指定类型参数
块引用>解决方案接受的SelectMany对象的集合,每个人都有一个内置集合属性。
您的第一个语句选择的申请收集和运行在其上的SelectMany似乎没有意义。
结帐这些链接来了解更好的SelectMany
http://msdn.microsoft.com/en-us/library/ bb534336.aspx 结果
差异之间的选择和的SelectManyWhile 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
解决方案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这篇关于该类型参数的方法“System.Linq.Queryable.SelectMany System.Linq.IQueryable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!