Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The any/all feature is only usable inside the filter expression and it is used to query based on related entities or collection properties. If you want to check just for existence of an employee without any relationship, you can do that without any/all. The idea is to simply filter all employees on the given condition and see if you get at least 1 result back.</p> <p>Now since you're doing this in Silverlight, the operation must be asynchronous, so a simple statement like above will not work. You could do something like:</p> <pre><code>var query = (DataServiceQuery&lt;Employee&gt;)this.Context.Employees.Where(e =&gt; e.PersonalNr.ToLower() == personalNr.ToLower()).Take(1); query.BeginExecute((ar) =&gt; { var results = query.EndExecute(ar); // The usage of Any here is simply because it's the easiest way to do this // and it is not used over OData/WCF DS, this is simply checking if the results returned // from the service contain at least one result. bool employeeExists = results.Any(); }, null); </code></pre> <p>Few notes about the code above:</p> <p>The WCF Data Services doesn't support the Equals method with comparison options and the OData protocol doesn't support case insensitive string comparison either. So to workaround that, simply convert all values to lower case before comparing.</p> <p>The Take(1) is used to only ask for the first value which matches the condition. Since we're only gonna use the existence of the result anyway, we don't need to ask the service for all the results (small optimization).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload