c# - What can I use instead of Where clause in Asyn method? -
i have project in c# , entity framework. need convert of methods of repository async. have problem converting method, not sure can use instead of clause.
public async task<ienumerable<product>> getproductbyyearidasync(int yearid) { return await applicationscontext.product.where(product=> product.yearid == yearid); }
when use gave me error cannot await iqueryable. when use firstordefaultasync lot know how convert ienumerable.
where
not execute query, there nothing "asynchronous" invoking where
. need invoke tolistasync
executes query asynchronously.
public async task<ienumerable<product>> getproductbyyearidasync(int yearid) { return await applicationscontext.product .where(product=> product.yearid == yearid).tolistasync(); }
Comments
Post a Comment