开发者

Dynamically query an object set in EF using LambdaExpression

开发者 https://www.devze.com 2023-03-16 03:06 出处:网络
I am trying to dynamically query Entity Framework, so I\'m using the Expression class to put together a LambdaExpression that will be queried against an object set.If I have a reference to LambdaExpre

I am trying to dynamically query Entity Framework, so I'm using the Expression class to put together a LambdaExpression that will be queried against an object set. If I have a reference to LambdaExpressi开发者_JAVA技巧on, where I don't have an explicit function defined, is it possible to query against an objectset this way, or is it required to have a generic expression defined (using Expression.Lambda<..>)?

Thanks.


This is what I was looking to do:

http://msdn.microsoft.com/en-us/library/bb882637.aspx

Using this, I was able to build a lambda expression against an object set dynamically. Worked very well.


Check out Dynamic Linq. Basically you can use strings in place of LINQ expressions until you want to use them. Sounds like it might be what you want.

0

精彩评论

暂无评论...
验证码 换一张
取 消