vb.net return only selected columns/fields from linq.IQueryable(of out t) -


sorry english.

i have been searching web "dynamic linq queries" , found 1 works on me. guide creating dynamic linq queries. converted vb on online converter. , result

  public shared function getfiltereddatawithpage(customer string, itemdesc string, jonumber string)     dim db new jodataclassesdatacontext     dim dataquery iqueryable(of jomaintbl) = db.jomaintbls      if customer.trim().length > 0         dataquery = dataquery.where(function(a) a.customer.startswith(customer))     end if     if itemdesc.trim().length > 0         dataquery = dataquery.where(function(a) a.itemdescription.startswith(itemdesc))     end if     if jobnumber.trim().length > 0         dataquery = dataquery.where(function(a) a.jonumber = jonumber)     end if     return dataquery   end function 

i have table 5 fields

"jonumber, sample, datecreated, customer, itemdesc"

and display it

datagridview.datasource = getfiltereddata(txtcustomer.text, txtitemdesk.text, txtjobnumber.text) 

the problem want display fileds "jonumber, customer, itemdesc" , in order. appreciated. thank in advance.

as @marcinjuraszek suggested in comment, should use select this:

  public shared function getfiltereddatawithpage(customer string, itemdesc string, jonumber string)      dim db new jodataclassesdatacontext     dim dataquery iqueryable(of jomaintbl) = db.jomaintbls      if customer.trim().length > 0         dataquery = dataquery.where(function(a) a.customer.startswith(customer))     end if     if itemdesc.trim().length > 0         dataquery = dataquery.where(function(a) a.itemdescription.startswith(itemdesc))     end if     if jobnumber.trim().length > 0         dataquery = dataquery.where(function(a) a.jonumber = jonumber)     end if     return dataquery.select(function(x) new {.jonumber=x.jonumber, .customer=x.customer, .itemdesc=x.itemdesc})   end function 

Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -