c# - How to incorporate criteria in Where method? -
i want ask condition in search command. i'm calling web service (api) during searching , want put statement in code there's error.
private async task callapi(string searchtext = null) { long lastupdatedtime = 0; long.tryparse(appsettings.complaintlastupdatedtick, out lastupdatedtime); var currenttick = datetime.utcnow.ticks; var time = new timespan(currenttick - lastupdatedtime); if (time.totalseconds > 1) { int stafffk = convert.toint32(staffid); var result = await mdataprovider.getcomplaintlist(lastupdatedtime, mcts.token, stafffk); if (result.issuccess) { // save last updated time appsettings.complaintlastupdatedtick = result.data.updated.tostring(); // store data database if ((result.data.items != null) && (result.data.items.count > 0)) { var datas = new list<complaint>(result.data.items); **if (!string.isnullorempty(searchtext)) { datas = datas.where(i => i.description.contains(searchtext) && (i.supervisorid.equals(staffid)) || (i.problemtypename.contains(searchtext))); } else { datas = datas.where(i => i.supervisorid.equals(staffid)); }** datas = new observablecollection<complaint>(datas); } } else if (result.haserror) { await mpagedialogservice.displayalertasync("error", result.errinfo.message, "ok"); } } } both assignments of datas in if ... else causes system.collections.generic.ienumerable<ecs.features.complaints.complaint>' 'system.collections.generic.list<ecs.features.complaints.complaint>'. explicit conversions exists (are missing cast?) compilation errors:
i don't know how use condition there. please me. thank in advance concern.
datas list<complaint> try reassign ienumerable<complaint> where statement. add tolist() after maintain type,
or declare datas ienumerable<complaint>
ienumerable<complaint> datas = new list<complaint>(result.data.items); 
Comments
Post a Comment