Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to write below condition in EF 3.5 Query. Below in SQL format.

SQL
a.member in ('Free','PartTime') and (DATEDIFF(m,asofdate,getdate())>0 or AsOfDate is null)
Posted
Updated 9-Feb-12 7:43am
v2

Have a look at http://www.linqpad.net/[^]

LINQPad lets you interactively query databases using linq - it's a useful tool for trying out queries.

I'm also pretty certain that I would use ExecuteStoreQuery[^] and just execute the query using your SQL.

I expect that you know that your query will be translated back to SQL because SQL server hasn't got a clue about linq.

Best regards
Espen Harlinn
 
Share this answer
 
Comments
thatraja 11-Feb-12 9:58am    
5!
Espen Harlinn 11-Feb-12 10:13am    
Thank you, thatraja :)
It's LINQ you are using. use DateTime.Now to get the current date, and then compare it from there. Do you know how to write LINQ queries ?
 
Share this answer
 
Comments
divesh12 9-Feb-12 13:57pm    
var team = from a in Entity.Report.Where(a=> a.Active == true) select a;
This is my Query want to add in this query. Can you please add for me.
divesh12 9-Feb-12 13:58pm    
a.member in ('Free','PartTime') and (DATEDIFF(m,asofdate,getdate())>0 or AsOfDate is null)
Please add this in LINQ format in where statement.
Christian Graus 9-Feb-12 13:59pm    
var team = from a in Entity.Report.Where(a=> a.Active == true && (a.member == "Free" || a.Member == "PartTime") && (a.AsOfDate == null || a.AsOfDate > DateTime.Now)

That is an absolute wild guess.
divesh12 13-Feb-12 8:07am    
var team = from a in Entity.Report where ( (a.Active == true) && (a.Member == "Free" || a.Member == "PartTime") && (a.AsOfDate > DateTime>now || a.AsOfDate == null))
divesh12 13-Feb-12 8:07am    
Thanks Christian

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900