WCF 操作合同和 Nhibernate ICriteria

发布于 2024-07-14 04:57:05 字数 420 浏览 1 评论 0原文

我们正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

治碍 2024-07-21 04:57:05

这不是一个很酷的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文