none
How do I do a compound Where clause RRS feed

  • Question

  • In SQL Server I have the following query:

    Select * From TestLogRecord Where TestSetupID = 133
    And ((CommentLeft Not Like '%Spike%') Or (CommentLeft Is Null))

    I am not sure how to add the compound if in EF; here is what I have but it omits the null records:

    logs = db.TestLogRecord.Where(x => x.TestSetupId == id).

    Where(x => !x.CommentLeft.Contains("Spike")).ToList();


    How do an Or clause in one statement?

    Thank you

    Tuesday, December 8, 2015 9:25 PM

Answers

  • I figured it out!

    db.TestLogRecord.Where(x => x.TestSetupId == id).Where(x => !x.CommentLeft.Contains(

    "Spike") || (x.CommentLeft == null)).ToList();

    • Marked as answer by Data.Jugggler Tuesday, December 8, 2015 9:35 PM
    Tuesday, December 8, 2015 9:35 PM