Click here to Skip to main content
15,905,504 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am a new one to LINQ and EF and trying to convert a query into LINQ.But unable to get it.


SQL
select  TU.username, TU.email, TL.Logid from TBL_A TU
left join  TBL_B TL on tu.userid = TL.userid
 where TU.teamid = 1001
 and Convert(Date,TL.logindt) = Convert(Date,getdate())
 and logid not in (select logid from  TBL_C where scheduleid = 8)



I have tried different approaches,

Tried to divide the query in subqueries and so on,, but unable to succeed.

ANy help would be appreciated.
Posted

1 solution

Can you try the below LINQ query.

Hope that this one helps you out...
You might be needed to check the WHERE clause.

var query =( from TU in TBL_A 
	  join TL in TBL_B on  TU.userid equals TL.userid
	  where TU.teamid = 1001
	  select new 
	  {
		TU.username, 
		TU.email, 
		TL.Logid
	  }).ToList();
 
Share this answer
 
Comments
VICK 22-May-14 23:59pm    
You have just wrote the respective LINQ for the first part of query.. remaining 2 are still to be implemented and are actually the problematic part for me... :(

and secondly you missed the second where clause as well.. i.e.

and Convert(Date,TL.logindt) = Convert(Date,getdate())
Kumar Prateek 3-Jun-14 10:07am    
Do let us know your solution for the same.
And I have already specified that you need to check the where clause which can be done very easily with the .net libraries.

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