LINQ的错误"未能找到源类型的查询模式的实现“System.Linq.IQueryable”加入未找到“未找到、错误、类型、模式

2023-09-07 04:50:19 作者:hobo(流浪者)

什么是地狱意思?忽略的回报,而得到的,其结果将被夷为平地,并停留在应用MEM(所以这将是一个集...可能) 未能找到源类型System.Linq.IQueryable的查询模式的实现。加入未找到。考虑显式指定范围变量a的类型。的

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'."

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两个数组,dCountries是.toArray()

dRegions/dAreas Both arrays, dCountries is .toArray()

推荐答案

阵列是一个非常松散的类型,并且不执行的IEnumerable< T> 等,你可以尝试只切换阵列 VAR (让编译器挑式)。如果仍然使用阵列,那么也许使用 .Cast< T>()指定类型(或 Array.ConvertAll 等)。

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).

阵列(没有更多的信息),它只知道对象

From Array (without more information) all it knows is object.

基本上,加入定义(作为一个扩展的方法)对的IEnumerable&LT; T&GT; 的IQueryable&LT; T&GT; - 不是的IEnumerable (不包括&LT; T&GT;

Basically, Join is defined (as an extension method) on IEnumerable<T> and IQueryable<T> - not IEnumerable (without the <T>).