c# - Cannot assign a void to an implicitly-typed local variable using Entity Framework 6 -
i using wcf refrence call last row quote table. wrote method in wcf application last row, not know it works or not(i trying test it):
public void getlastquote() { using (truckdb db = new truckdb()) { var quote = (from qdata in db.quotes qdata.id == qdata.represetativeid orderby qdata.id descending select qdata).first(); } } in wpf application using wcf reference , calling on getlastquoteasync() method, giving me following error:
cannot assign void implicitly-typed local variable
and here method in wpf application trying call getlastquoteasync() reference.
private async void wlistofbills_loaded(object sender, routedeventargs e) { using (truckserviceclient client = new truckserviceclient()) { var quote = await client.getlastquoteasync(); // -> error lies. var bills = await client.getlistofbillsasync(quote.item.id); if (bills == null) { dgfloor.isenabled = true; return; } dgfloor.itemssource = bills.select(x => new listofbillsview { code = x.stockcode, group = x.groupname, description = x.stockdescription, qty = x.quantity, length = x.length, width = x.width, weight = x.weight, price_m = x.pricepermeter, cost = x.cost, section = x.trucksection.tostring() }).tolist(); } } i have seen people same question, not understand how implement solutions in own problem. if help, appreciate allot! :)
you want call query returning, method wrapping around query returning nothing, because type void.
i assume want return object of type quote, need change method this:
//change void quote public quote getlastquote() { using (truckdb db = new truckdb()) { var quote = (from qdata in db.quotes qdata.id == qdata.represetativeid orderby qdata.id descending select qdata).first(); //new return quote; } } also getlastquote() not same getlastquoteasync() have posted wrong method, throw same error?
if there async version of method should similar this:
public async task<quote> getlastquote() { using (truckdb db = new truckdb()) { var quote = (from qdata in db.quotes qdata.id == qdata.represetativeid orderby qdata.id descending select qdata).firstasync(); /*note async method here*/ //new return await quote; } }
Comments
Post a Comment