locked
Is it possible to do a Greater than or Less than comparison between strings in a where clause of a LINQ to CRM query RRS feed

  • Question

  • Hi,

    I'm trying to write a LINQ to CRM query where I retrieve records with a string field > a certain value.

    E.g.

    from MySystemUser in SystemUserIQuerable

    where MySystemUser .FullName < "SomeName"

    orderby MySystemUser .FullName

    While == and != are supported,   >, <, >= etc. are not supported. Also the string method Compare is also not support???   MySystemUser.FullName.Compare("SomeName")


    Andy

    Friday, July 12, 2013 2:56 PM

All replies

  • do something like:-

    AllApplications.Where(x => string.Equals(x.Name, txtSearch.Text, StringComparison.OrdinalIgnoreCase)).ToList();


    Regards Faisal

    Friday, July 12, 2013 3:16 PM
  • Hi,

     I know that .Equals works, what I'm trying to do is   x.Name > "123"

    String greater than operator


    Andy

    Friday, July 12, 2013 4:16 PM
  • Hi,

    Instead of 

    where MySystemUser.FullName < "SomeName"

    try to use

    where String.Compare(MySystemUser.FullName,"SomeName") >= 0

    stringA.Compare(stringB) and String.Compare(stringA,stringB) are different methods.

    The second one should be supported by LINQ.

    Best regards

    Steve


    Steve Sämmang, Vienna, Austria
    Blog: xrm.io Website: simplic.at


    • Edited by saemmang Saturday, July 13, 2013 7:09 AM clarification
    Friday, July 12, 2013 6:49 PM