Print Page | Close Window

Handling and/or in lambda expression

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2455
Printed Date: 16-Apr-2025 at 11:26am


Topic: Handling and/or in lambda expression
Posted By: BillG
Subject: Handling and/or in lambda expression
Date 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);

 




Replies:
Posted By: BillG
Date 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.



Print Page | Close Window