This question is locked. New answers and comments are not allowed.
Dear all,
When I use a LinqKit query in a telerik grid, I cannot add aggregates, I get this error message:
And the function public static bool IsEntityFrameworkProvider(this IQueryProvider provider)
{
return provider.GetType().FullName == "System.Data.Objects.ELinq.ObjectQueryProvider" ||
provider.GetType().FullName.StartsWith("System.Data.Entity.Internal.Linq");
}
As LinqKit has an another provider name, it is not recognized as an entityframework provider while it is an entity framework provider, it is just an extension to the regular provider.
How can I solve this problem without having to modify the sources of Telerik Grid ?
Thank you in advance.
When I use a LinqKit query in a telerik grid, I cannot add aggregates, I get this error message:
Unable to cast the type 'System.Int32' to type 'System.Object'. LINQ to Entities onlysupports casting Entity Data Model primitive types.
After some debugging I found that the problem is the function CreateKeyMemberBinding(), which contains
// Our Key property is of type object so we need to box if the value is ValueType.
// EF did not support convert so did not call it.
// Note: We can fix all this if our group is generic type similar to IGrouping<TKey, TElement>
if (keyPropertyExpression.Type.IsValueType &&
!this.Queryable.Provider.IsEntityFrameworkProvider())
{
keyPropertyExpression = Expression.Convert(keyPropertyExpression, typeof(object));
}
And the function public static bool IsEntityFrameworkProvider(this IQueryProvider provider)
{
return provider.GetType().FullName == "System.Data.Objects.ELinq.ObjectQueryProvider" ||
provider.GetType().FullName.StartsWith("System.Data.Entity.Internal.Linq");
}
As LinqKit has an another provider name, it is not recognized as an entityframework provider while it is an entity framework provider, it is just an extension to the regular provider.
How can I solve this problem without having to modify the sources of Telerik Grid ?
Thank you in advance.