Not Equal C && !=C && 不等于西
RSS icon Email icon Home icon
  • Predicates in Lambda Expression for Entity Framework Code First

    Posted on July 24th, 2013 Sean 1 comment

         If I have 2 entities of “People” and “Car”, and “1” People can have “Many” Car, my code first class could be like below:


         Let’s say, if we want to find the person who name is “Sean”, and has a car of maker “GMC” by using lambda Predicates, we probably need to do like below:

         What if I want to compose above 2 lambda to 1? Unfortunately there is no easy way to simply join multiple lambda by whatever “AND” or “OR”, specially if navigation properties involved like the example above.
         From Colin Meek’s Blog, we can manually write a general utility method to compose lambda expressions

         By using this utility, we can write our code simply like below

    1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
    Loading...Loading...
    559 views

    Leave a Reply

    1 Comment on "Predicates in Lambda Expression for Entity Framework Code First"


    Guest
    Clarissa
    09/12/2014

    I read a lot of interesting posts here. Probably you spend a lot of time writing, i know how to save you a lot of time, there is

    an online tool that creates high quality, SEO friendly articles in minutes,

    just type in google – laranitas free content source