WCF 操作合同和 Nhibernate ICriteria
我们正在尝试使用 WCF 和 ICriteria 创建一个很酷的 API,例如:
[ServiceContract]
public class ProductService
{
[OperationContract]
public List<Product> Get()
[OperationContract]
public List<Product> GetByCriteria(Criteria criteria)
}
我们正在考虑使用 DetachedCriteria,以便任何人都可以发送它,并将其连接到服务中的会话,以便在数据库前面运行查询。
有没有人创建这样的API? 我们应该使用 Nhibernate 的 ICriteria 吗? 还有其他很酷的想法吗?
谢谢。
We are trying to create a cool API using WCF and ICriteria, for example:
[ServiceContract]
public class ProductService
{
[OperationContract]
public List<Product> Get()
[OperationContract]
public List<Product> GetByCriteria(Criteria criteria)
}
We are thinking of using the DetachedCriteria so anyone can send it and we connect this to the Session in the Service for running the Query infront of our DB.
Is there anyone who create such API?
Should we use the ICriteria from Nhibernate?
Any other cool Ideas?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这不是一个很酷的 API。 它是面向对象的,而不是面向服务的。 这是行不通的。
您必须使用 KnownTypeAttribute(或 ServiceKnownTypeAttribute)进行多态查询。 (请参阅此问题)。
另外,这不是一个非常优雅的解决方案,我会劝阻您这样做。 在服务世界中要明确。
This is not cool API. It's object oriented, not service oriented. And it will not work.
You will have to use KnownTypeAttribute (or ServiceKnownTypeAttribute) for polymorphic queries. (see this question).
Also this is not very elegant solution and I would discourage you from that. Be explicit when in Service World.