C# – Linq Error “Could not find an implementation of the query pattern for source type ‘System.Linq.IQueryable’ Join Not Found’

.net-3.5asp.net-mvccc#-3.0

What 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 Both arrays, dCountries is .toArray()

Best Answer

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.

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