简体   繁体   中英

Converting SQL to LINQ

I have a specific SQL query:

SELECT TOP 20 * FROM tblIm WHERE Id NOT IN (SELECT TOP  20  Id FROM tblIm)

I just tried this:

var results = from myRow in Ds.AsEnumerable().Take(minRecords)
              where myRow.Field<int>("Trail_Id") > 1 
              && myRow.Field<int>("Id") <= 20
select myRow;

but it's not working as i want. So how do I convert it to a LINQ statement that works like the SQL statement?

Any suggestions?

Thank you all But I got Solution finally :

var testresult = from c in  Ds.AsEnumerable().Take(20) 
                         where !(from o in Ds.AsEnumerable().Take(intSkip)    
                         select o)    
                        .Contains(c)    
                        select c;

我认为那会像

tblIm.Skip(20).Take(20)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM