locked
Logical operator in Where Clause RRS feed

  • Question

  • In SQL, it's very easy if we waent to use logical in where clause Ex. Where (Name = 'John' AND PhoneNumber = '8409876543').

    How  can i use it in LINQ to Entity. Pls give me some code example.

    thank you.

    Wednesday, July 20, 2011 9:27 AM

Answers

  • Hi,

    in LINQ it is as well simple as that:

    var people = from p in Persons where p.Name.Equals("John") && p.PhoneNumber.Equals("84094") select p;

    Dani


    http://dotnet-experience.blogspot.com/
    • Marked as answer by hungdoan Thursday, July 21, 2011 1:29 AM
    Wednesday, July 20, 2011 2:10 PM
  • or

    Var people = Persons.Where(p=>p.Name.Equals("John") && p.PhoneNumber.Equals("5675309"));


    JP
    • Marked as answer by hungdoan Thursday, July 21, 2011 1:30 AM
    Wednesday, July 20, 2011 2:31 PM

All replies

  • Hi,

    in LINQ it is as well simple as that:

    var people = from p in Persons where p.Name.Equals("John") && p.PhoneNumber.Equals("84094") select p;

    Dani


    http://dotnet-experience.blogspot.com/
    • Marked as answer by hungdoan Thursday, July 21, 2011 1:29 AM
    Wednesday, July 20, 2011 2:10 PM
  • or

    Var people = Persons.Where(p=>p.Name.Equals("John") && p.PhoneNumber.Equals("5675309"));


    JP
    • Marked as answer by hungdoan Thursday, July 21, 2011 1:30 AM
    Wednesday, July 20, 2011 2:31 PM
  • thank you very much.
    Thursday, July 21, 2011 1:30 AM