title: Standards for queries over SOAP
body: <p>Is there a standards-sanctioned XML format for describing entity queries? </p>
  
  <p>Background: I plan to build a library for writing queries over WCF services.  </p>
  
  <p>On the client I want to be able to write (C#):</p>
  
  <pre><code>var customers = from c in service.Customers
                  where c.Name.StartsWith("P")
                  order by c.Name
                  select c;
  </code></pre>
  
  <p>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:</p>
  
  <pre><code>&lt;query&gt;
    &lt;fetch entity="Customer"&gt;
       &lt;all-attributes /&gt;
       &lt;filter type="and"&gt;
         &lt;condition attribute="Name" operator="starts-with" value="P" /&gt;
       &lt;/filter&gt;
       &lt;order-by attribute="Name" /&gt;
    &lt;/fetch&gt;
  &lt;/query&gt;
  </code></pre>
  
  <p>On the server side, the operation would look something like this:</p>
  
  <pre><code>public ResultSet Query(Query query)
  {
      using (var dataContext = new AdventureWorksDataContext()) 
      {
          var expression = query.ToExpressionTree();
          var sqlQuery = dataContext.CreateQuery(expression);
          return ResultSet.From(sqlQuery);
      }
  }
  </code></pre>
  
  <p>Since the query is just XML, my hope is other clients will also be able to use it easily enough. </p>
  
  <p>My question is, is there already an XML schema that describes queries like this?</p>
  
  <p>The one that inspired me was Microsoft CRM's FetchXML:</p>
  
  <p><a href="http://msdn.microsoft.com/en-us/library/ms936573.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms936573.aspx</a></p>
  
  <p>Have any of the web services standards bodies defined a schema for queries over web services? Any other suggestions?</p>