当前位置:网站首页>Findasync and include LINQ statements - findasync and include LINQ statements

Findasync and include LINQ statements - findasync and include LINQ statements

2022-06-12 06:00:00 Bustling city

problem :

The code I have got so far works fine The code I've got so far works well

public async Task<ActionResult> Details(Guid? id){    if (id == null)    {        return new HttpStatusCodeResult(HttpStatusCode.BadRequest);    }    ItemDetailModel model = new ItemDetailModel();    model.Item = await db.Items.FindAsync(id);    if (model.Item == null)    {        return HttpNotFound();    }    return View(model);}

But I want to include 1 table more and cannot use FindAsync But I want to include more 1 Tables and cannot be used FindAsync

public async Task<ActionResult> Details(Guid? id){    if (id == null)    {        return new HttpStatusCodeResult(HttpStatusCode.BadRequest);    }    ItemDetailModel model = new ItemDetailModel();    model.Item = await db.Items.Include(i=>i.ItemVerifications).FindAsync(id);    if (model.Item == null)    {        return HttpNotFound();    }               return View(model);}

So I am facing this error So I face this mistake

Severity Code Description Project File Line Suppression State Error CS1061 'IQueryable' does not contain a definition for 'FindAsync' and no extension method 'FindAsync' accepting a first argument of type 'IQueryable' could be found (are you missing a using directive or an assembly reference?) The severity code indicates that the project file line suppression status is wrong CS1061“IQueryable” It doesn't contain “FindAsync” The definition of , And can't find an acceptance “IQueryable” Extension method of the first parameter of the type “FindAsync”( Are you missing using Instruction or assembly reference ?)

Any clue how to fix it? Any clue how to solve it ?


Solution :

Reference resources : https://stackoom.com/en/question/2jLc0
原网站

版权声明
本文为[Bustling city ]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203010613484229.html