wcf 表达式范围
我正在尝试执行类似于在 WCF 操作参数中使用 lambda 查询的操作。我知道没有办法实现这一点,因为 lambda 表达式是运行时的,不能以这种方式使用它们,但我认为有一些解决方案。我的第一个想法是使用一些搜索条件类,以便我可以填充此类,然后在服务器端使用它来构建 lambda 表达式。我对此类的简单实现的想法是这样的:
public class PersonSearchCriteria
{
public string FirstName {get; set;}
public string LastName {get; set;}
public int IdCardNumber {get; set;}
Expression<Func<TSource, bool>> predicate
}
这是一些伪代码。我希望能够创建此类的实例,并根据此属性值在数据库上下文中过滤数据库(在本例中是带有 selft 跟踪实体的 EntityFramework 4.0)。
I am trying to do something similar to using a lambda query inside a WCF operation parameter. I know there is no way to achieve this as lambda expressions are run-time and they can not be used in this way, but I think there are some solutions for this. My first idea is to use some search criteria class so that I can populate this class and then use it on server-side to build a lambda expression. My thoughts on a simple implementation for this class is something like :
public class PersonSearchCriteria
{
public string FirstName {get; set;}
public string LastName {get; set;}
public int IdCardNumber {get; set;}
Expression<Func<TSource, bool>> predicate
}
This is some pseudo code. I want to be able to create an instance of this class and based on this properties values' filter my database in my databasecontext (which in this case is EntityFramework 4.0 with selft tracking entities).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了一些文章:
我通过搜索找到了这个关于 wcf 序列化表达式
I found some articles:
I found this by searching on wcf serialize expression