Click here to Skip to main content
15,889,909 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
How to conver this to LINQ?

SQL
SET @APPLED_STATUS      =1
    SET @RECOMMENDED_STATUS =2
    SET @APPROVED_STATUS    =3
    SET @NOTCANCELLED_STATUS=7
    SET @SPLREQUESTED_STATUS = 9
    SET @HRAREQUESTED_STATUS = 12


LR.LeaveStatus_Id IN (@APPLED_STATUS,@RECOMMENDED_STATUS,@APPROVED_STATUS,@NOTCANCELLED_STATUS,@SPLREQUESTED_STATUS,@HRAREQUESTED_STATUS)


I have tried this:
int APPLED_STATUS   =1;
int RECOMMENDED_STATUS  =2;
int APPROVED_STATUS =3;
int NOTCANCELLED_STATUS=7;
int SPLREQUESTED_STATUS = 9;
int HRAREQUESTED_STATUS = 12;{APPLED_STATUS,RECOMMENDED_STATUS,APPROVED_STATUS,NOTCANCELLED_STATUS,SPLREQUESTED_STATUS,HRAREQUESTED_STATUS}.Contains(LR.LeaveStatus_Id)

But this is not working..
Posted
Updated 20-Aug-13 1:35am
v3
Comments
Jameel VM 20-Aug-13 8:05am    
please post the complete query and code.

If I get what you are trying to do

from this sample SQL

SQL
SELECT *
FROM sampleTable
WHERE id IN (1,2,3,4,7,9)


into LINQ

C#
 int[] flags = new int[] {1,2,3,4,7,9};
 list<int> data =new list<int>() {1,2,3,4,5,6,7,8,9,0};

 var results = from val in data where flags.Contains(val) == true select val;
</int></int>


If I am wrong please expand on your question so that we can help.
 
Share this answer
 
Comments
fjdiewornncalwe 20-Aug-13 11:34am    
+5. Looks right to me.
Simon_Whale 20-Aug-13 11:34am    
Thanks Marcus
kodoth 21-Aug-13 0:20am    
Thank you.. This code is working.. :)
Simon_Whale 21-Aug-13 3:21am    
your welcome :)
To convert SQL to LINQ, you can use the tool Linqer:
http://sqltolinq.com/[^]
 
Share this answer
 

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