C# Linq 错误“找不到源类型‘System.Linq.IQueryable’Join Not Found 的查询模式的实现”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1127767/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Linq Error "Could not find an implementation of the query pattern for source type 'System.Linq.IQueryable' Join Not Found'
提问by Chris McKee
What the hell does this mean?Ignore the return, and the get, The results will be flattened and stuck in the application mem (so this will be a set... probably)
"Could not find an implementation of the query pattern for source type 'System.Linq.IQueryable'. 'Join' not found. Consider explicitly specifying the type of the range variable 'a'."
这到底是什么意思?忽略返回和获取,结果将被展平并卡在应用程序内存中(所以这将是一个集合......可能)
“找不到源类型'System.Linq.IQueryable的查询模式的实现'。未找到 'Join'。考虑明确指定范围变量 'a' 的类型。
private CommonDataResponse toCommonData
{
get
{
CommonDataResponse toCommonData = this.gatewayReference.GetCommonData();
Array dCountries = toCommonData.PropertyCountries.ToArray(); //Webservice sends KeyValuePairOfString
Array dRegions = toCommonData.Regions; //Webservice sends Array
Array dAreas = toCommonData.Areas; //Webservice sends Array
var commonRAR = from a in dAreas
join r in dRegions
on a.RegionID equals r.Id
join c in dCountries
on r.CountryCode equals c.Key
select new {c.Value, r.Name, a.Name, a.Id };
return toCommonData;
}
}
dRegions/dAreas Both arrays, dCountries is .toArray()
dRegions/dAreas 都是数组,dCountries 是 .toArray()
采纳答案by Marc Gravell
Array
is a very loose type, and doesn't implement IEnumerable<T>
etc. You could try just switching the Array
lines to var
(let the compiler pick the type). If it still uses Array
, then perhaps use .Cast<T>()
to specify the type (or Array.ConvertAll
, etc).
Array
是一种非常松散的类型,并且没有实现IEnumerable<T>
等。您可以尝试将Array
行切换为var
(让编译器选择类型)。如果它仍然使用Array
,则可能用于.Cast<T>()
指定类型(或Array.ConvertAll
等)。
From Array
(without more information) all it knows is object
.
从Array
(没有更多信息)它只知道object
.
Basically, Join
is defined (as an extension method) on IEnumerable<T>
and IQueryable<T>
- not IEnumerable
(without the <T>
).
基本上,Join
定义(作为扩展方法)IEnumerable<T>
和IQueryable<T>
- 不IEnumerable
(没有<T>
)。