通过 SOAP 进行查询的标准

发布于 2024-07-24 09:54:46 字数 1310 浏览 4 评论 0原文

是否有标准认可的 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 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文