Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I don't think (from my tests and experiments) that you can pass parameters of type <code>DateTime</code> directly. After all, in the end (after all the niceties of the WCF DataService client-side proxy and its LINQ-to-WCF goodness), WCF Data Services is always getting its parameters from the URL query string, so basically, it's all just strings....</p> <p>(this is in stark contrast to using the SOAP bindings for WCF - there, you can definitely use strongly typed parameters - <code>DateTime</code> and anything you like. But WCF Data Services is REST, it's all URL- und thus string-based)</p> <p>So my conclusion is: you need to change your code to use <code>string</code> parameters and then converts those to <code>DateTime</code> inside your method:</p> <pre><code>[WebGet] public IQueryable&lt;Job&gt; LoadJobsByDate(string startDate, string endDate) { // some error checking needs to be done here! If 'startDate' or 'endDate' // are NULL or emtpy string --&gt; fall back to a default // also - you might want to check into .ParseExact and define a list of valid, // supported date formats that you want to offer your users DateTime startDt = DateTime.Parse(startDate); DateTime endDt = DateTime.Parse(endDate); var context = this.CurrentDataSource; var jobs = from j in context.Jobs where j.CreatedDate &gt;= startDt &amp;&amp; j.CreatedDate &lt;= endDt select j; return jobs; } </code></pre> <p>As I mentioned in the code snippet - having to get strings and parse them into <code>DateTime</code> requires that you do some additional error checking on your part - it's a pain, but I think it's necessary to make sure your code doesn't break the first time someone enters no date or an invalid date format....</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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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