简体   繁体   中英

How to Convert ADO.NET to LINQ?

"SELECT TOP " + this.mintPageSize + " * FROM tblGroupDetail WHERE GroupDetailId NOT IN " + "(SELECT TOP " + intSkip + " GroupDetailId FROM tblGroupDetail)")

How Convert this Query to Linq.SomeOne tell me with Code?i have tried

var innerQuery = (from fb in db.tblGroupDetails where fb.GroupDetailID select fb).Take(this.mintPageSize); var result = from f in db.tblGroupDetails where innerQuery.Contains(f.GroupDetailID) select f;

I suspect you just need:

var query = db.GroupDetail
              .OrderBy(...) // You really need an ordering
              .Skip(intSkip)
              .Take(mintPageSize);

You should work out what ordering you want, otherwise "the first N" doesn't have any meaning.

That's not a translation of your query so much as your intent - you should check what SQL it generates.

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