How to generate equivalent query by LINQ c# -
this in-line sql query. same equivalent query generated linq.
var lowerpageboundary = 0; var tablename = "orders"; var columntosortby = "orderid"; var sortcolumn = "orderid"; var rowsperpage = 16; var commaseparatedlistofcolumnnames = "orderid,customerid,employeeid "; var sql = "select top " + rowsperpage + " " + commaseparatedlistofcolumnnames + " " + tablename + " " + columntosortby + " not in (select top " + lowerpageboundary + " " + columntosortby + " " + tablename + " order " + sortcolumn + ") order " + sortcolumn;
this linq query far. tell me how customize output above in-line sql query.
xdocument document = xdocument.load(xmlfilepath); var query = r in document.descendants("orders") select new { orderid = r.element("orderid").value, customerid = r.element("customerid").value, employeeid = r.element("employeeid").value }; query = query.orderby(sortcolumn + " " + orderdirection);
how make nested above sql query , add pagination concept above sql one.
it'd easier if post original sql query, here's take:
document .where(x=> !documents.orderby(p=> p.orderid) .take(sortcolumn) .contains(x)) .select(p=> new {...}) .orderby(...).take(...)
edit:
or better yet:
var hashset = new hashset<whatever>( documents.orderby(p=> p.orderid) .take(sortcolumn)); document .where(x=> !hashset.contains(x)) .select(p=> new {...}) .orderby(...).take(...)
Comments
Post a Comment