c# - Searching database with Linq -
i trying search data in datagrid
using code sample below. have had working code looking bit different, going use async in coding , have tried sample below, have no idea how change code work correctly.
private async task btnsearchsysprostock_click(object sender, routedeventargs e) { using (dataentities de = new dataentities()) { list<ssdata> stocksearch = await (from in de.tblsysprostocks (a => txtsearchsysprostock.text == string.empty || a.stockcode.contains(txtsearchsysprostock.text)) //the error in line select new ssdata { sid = a.stockid, scode = a.stockcode, sdescription = a.stockdescription, sconvfactaltuom = (float)a.convfactaltuom, ... }).tolistasync(); dgsysprostock.itemssource = stocksearch; } }
i getting following error:
cannot convert lamba expression type 'bool' because not delegate type
can please me code using work. in advance! :)
linq where
clause expects bool
expression, don't need lambda here :
from in ... txtsearchsysprostock.text == string.empty || a.stockcode.contains(txtsearchsysprostock.text) select ...
Comments
Post a Comment