Home

Parametrized queries

Hi
Can I build "parametrized" queries with LINQPad?
I tried to do something like that:

var date = DateTime.Now.AddDays(3); // Parameter
from dvd in Dvds.Where(d => d.Date != date)
...
(As I cannot use the expression directly in my query)
Thanks in advance
Philippe

Comments

  • edited April 2013
    One of the benefits of LINQ is that you *can* use expressions directly in a query.

    Given that you're using the != operator, I'm guessing you want to match on just the date portion and not the time of day. So your query should look like this:

    var date = DateTime.Now.AddDays(3).Date; // Parameter
    var query = from dvd in Dvds.Where(d => d.Date.Date != date) ...
  • Actually my example failed to compile because I missed the comboBox C# Expression / C# Statement(s). Now, it works like I wanted.
    Awesome.
Sign In or Register to comment.