通过 SOAP 进行查询的标准
是否有标准认可的 XML 格式来描述实体查询?
背景:我计划构建一个用于通过 WCF 服务编写查询的库。
在客户端上,我希望能够编写 (C#):
var customers = from c in service.Customers
where c.Name.StartsWith("P")
order by c.Name
select c;
我将使用自定义序列化程序将 LINQ 查询转换为 XML 格式,以作为 SOAP 正文的一部分发送到服务器。 也许它看起来像这样:
<query>
<fetch entity="Customer">
<all-attributes />
<filter type="and">
<condition attribute="Name" operator="starts-with" value="P" />
</filter>
<order-by attribute="Name" />
</fetch>
</query>
在服务器端,操作看起来像这样:
public ResultSet Query(Query query)
{
using (var dataContext = new AdventureWorksDataContext())
{
var expression = query.ToExpressionTree();
var sqlQuery = dataContext.CreateQuery(expression);
return ResultSet.From(sqlQuery);
}
}
由于查询只是 XML,我希望其他客户端也能够足够轻松地使用它。
我的问题是,是否已经有一个 XML 模式来描述这样的查询?
给我启发的是 Microsoft CRM 的 FetchXML:
http://msdn.microsoft。 com/en-us/library/ms936573.aspx
是否有任何 Web 服务标准机构定义了用于通过 Web 服务进行查询的架构? 还有其他建议吗?
Is there a standards-sanctioned XML format for describing entity queries?
Background: I plan to build a library for writing queries over WCF services.
On the client I want to be able to write (C#):
var customers = from c in service.Customers
where c.Name.StartsWith("P")
order by c.Name
select c;
I will use a custom serializer to turn the LINQ query into an XML format to send as part of the SOAP body to the server. Maybe it would look something like this:
<query>
<fetch entity="Customer">
<all-attributes />
<filter type="and">
<condition attribute="Name" operator="starts-with" value="P" />
</filter>
<order-by attribute="Name" />
</fetch>
</query>
On the server side, the operation would look something like this:
public ResultSet Query(Query query)
{
using (var dataContext = new AdventureWorksDataContext())
{
var expression = query.ToExpressionTree();
var sqlQuery = dataContext.CreateQuery(expression);
return ResultSet.From(sqlQuery);
}
}
Since the query is just XML, my hope is other clients will also be able to use it easily enough.
My question is, is there already an XML schema that describes queries like this?
The one that inspired me was Microsoft CRM's FetchXML:
http://msdn.microsoft.com/en-us/library/ms936573.aspx
Have any of the web services standards bodies defined a schema for queries over web services? Any other suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论