You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public static class ObjectExtensionMethod
{
public static IEnumerable Select(this object source, Func<dynamic, dynamic> map)
{
foreach (dynamic item in source as dynamic)
{
yield return map(item);
}
}
public static IEnumerable<dynamic> Where(this object source, Func<dynamic, dynamic> predicate)
{
foreach (dynamic item in source as dynamic)
{
if (predicate(item))
yield return item;
}
}
}
the problem with this solution is getting all data from database after that applying the where statement. is there any way to apply where statement before getting the data from database with dynamic type.
any suggestions? dose EF 7 support dynamic types so we can look into upgrading our project?
The text was updated successfully, but these errors were encountered:
@owidat As you probably already realized this workaround will not help with LINQ providers that work by translating the LINQ query's expression tree to a server query, since in this case the predicate is not captured as an expression. From what I have heard making dynamic work with that flavor of LINQ query is a pretty hard problem. If some day the language team solves it we can consider supporting it. In the meanwhile there are other patterns we can look into (although not for the EF7 RTM time frame), e.g. those explained in #2282. I would actually like to encourage you to read that issue and provide feedback about what kind of dynamic support you need and why.
In the meanwhile, a solution I have seen applied is to emit strongly typed models at runtime. It is hard to do but it can be made to work with existing frameworks.
We are I build dynamic data context, linq is not support dynamic type we found this solution or workaround
http://jrwren.wrenfam.com/blog/2010/03/04/linq-abuse-with-the-c-4-dynamic-type/
public static class ObjectExtensionMethod
{
public static IEnumerable Select(this object source, Func<dynamic, dynamic> map)
{
foreach (dynamic item in source as dynamic)
{
yield return map(item);
}
}
}
the problem with this solution is getting all data from database after that applying the where statement. is there any way to apply where statement before getting the data from database with dynamic type.
any suggestions? dose EF 7 support dynamic types so we can look into upgrading our project?
The text was updated successfully, but these errors were encountered: