c# - Like methods for integer field in LINQ query -


the following code statement throws error can help?

 var results = c in dt.asenumerable()                sqlmethods.like(c.field<int>("design_no").tostring(),                                      "%" + auto_txt_desi.text.tostring() + "%,")                 select c;                 dataview view = results.asdataview();                 dt = view.totable();  

sqlmethods.like method linq-to-sql query database not linq-to-dataset subset of linq-to-objects. can use pure .net methods instead:

var rows = row in dt.asenumerable()            let design_no = row.field<int>("design_no").tostring()            design_no.contains(auto_txt_desi.text)            select row; 

msdn:

the sql server like functionality cannot exposed through translation of existing common language runtime (clr) , .net framework constructs, , unsupported outside of linq sql context. use of method outside of linq sql will throw exception of type notsupportedexception.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -