Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tony Kiernan 278 posts 341 karma points
    Jun 26, 2012 @ 13:55
    Tony Kiernan
    0

    Spaces in Where() clause

    I'm having an issue with a filtering function I have

    records = records.Where(function ==\"" + stringFunction + "\"");

    If

    string strFunction = "Function";

    I get back the records anticipated

    string strFunction = "Some Function";

    Nothing, despite there being nodes that should be returned.

    I'm getting the value (from a dropdown) by posting back a form

  • Douglas Ludlow 210 posts 366 karma points
    Jun 26, 2012 @ 15:48
    Douglas Ludlow
    0

    @Tony, the Razor Where clause is different from the standard LINQ Where. In Razor it's really only meant to take strings. From what I understand, this is because dynamic objects are being used. Anyhow, here's an example of the correct way to use strings in the Where clause to filter your collection:

    string value = "Some Value";
    records = records.Where("property == @0", value);

    Hopefully something like that will work better for you.

  • Tony Kiernan 278 posts 341 karma points
    Jun 26, 2012 @ 16:40
    Tony Kiernan
    0

    Cheers.

Please Sign in or register to post replies

Write your reply to:

Draft