Standards for queries over SOAP

我的未来我决定 提交于 2020-01-04 09:16:47

问题


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?

来源:https://stackoverflow.com/questions/989633/standards-for-queries-over-soap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!