New Posts New Posts RSS Feed: Handling and/or in lambda expression
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Handling and/or in lambda expression

 Post Reply Post Reply
Author
BillG View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 05-Dec-2007
Location: Monroe, MI
Posts: 233
Post Options Post Options   Quote BillG Quote  Post ReplyReply Direct Link To This Post Topic: Handling and/or in lambda expression
    Posted: 20-Jan-2011 at 6:42am
I have a query in my remote method that is using lambda expressions. The Where clause has both ands and ors in it so I need to use multiple parentheses to achieve the right answer. But it doesn't seem to like multiples parentheses.
 

public static EmplRange GetEmplRangeWithoutWage(EntityManager manager, Member member, DateTime? startDate, DateTime? endDate)

{

var query = manager.GetQuery<EmplRange>()

.Where((er => er.TradeCd == member.TradeCd || er.TradeCd == "ALL") && (er.EffDate <= endDate && (er.EndDate >= startDate || er.EndDate == null))

.Select(er => er);

 

Back to Top
BillG View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 05-Dec-2007
Location: Monroe, MI
Posts: 233
Post Options Post Options   Quote BillG Quote  Post ReplyReply Direct Link To This Post Posted: 20-Jan-2011 at 4:47pm
I figured it out. I just had to reverse some of the entries. I made the ands first and then ors towards the back and it seemed to work fine.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down