不能使用.ToListAsync()扩展方法(.net 4.7) [英] Can not use .ToListAsync() extension method (.net 4.7)

查看:1808
本文介绍了不能使用.ToListAsync()扩展方法(.net 4.7)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用扩展方法.ToListAsync(),但是由于某种原因,该扩展方法不适用于我.

Im am trying to use extension method .ToListAsync() but for some reason this extension method not available for me.

我的设置如下:

  • Web项目(.Net 4.7),我确实包含了using System.Data.Entity;
  • DataAcess项目(.Net 4.7)在这里我插入Entity Frame Work v6.2
  • Web Project (.Net 4.7) here i did include using System.Data.Entity;
  • DataAcess Project (.Net 4.7) here I interlude Entity Frame Work v6.2

我的Web项目确实引用了我的DataAccess项目.

My Web Project does reference my DataAccess project.

我不确定我哪里出错了.有人可以请教吗?

Im not sure where i went wrong. Can somebody please advise?

谢谢!

推荐答案

ToListAsync方法是

The ToListAsync method is part of the QueryableExtensions class which is in the System.Data.Entity namespace and part of the EntityFramework.dll library. This means that you need import the namespace (i.e. using System.Data.Entity;) as well as reference EntityFramework.dll.

请注意,在经典的.Net Framework项目中,引用不是可传递的.换句话说,如果要使用库中的类,则必须在每个项目中都引用它.但在.Net Core中,这已经发生了变化.

Note that in classic .Net Framework projects, references are not transitive. In other words, if you want to use classes from a library, you must reference it in every project. This has changed in .Net Core though.

这篇关于不能使用.ToListAsync()扩展方法(.net 4.7)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆