【问题标题】:Intellisense stopped working for Linq to EntitiesIntellisense 停止为 Linq to Entity 工作
【发布时间】:2014-04-06 23:56:29
【问题描述】:

我有这个简单的代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.Linq;
using GadNameSpace;


public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        GadEntities db = new GadEntities();
        var images = db.Images.Where(x => x.isApproved == true).ToList();

        Repeater1.DataSource = images;
        Repeater1.DataBind();
    }
}

现在如果我要编辑这一行:

var images = db.Images.  <--this is where intellisense is not working...

它以前工作过。相同的文件,相同的项目,相同的解决方案。 如果我手动编写代码并运行它,它工作正常。 我试过开始 > cmd > “devenv /ResetSettings” 我也尝试重新启动电脑。 问题仅在于 Linq 智能感知!对于其他任何智能感知工作都很好......

有什么好主意吗?

【问题讨论】:

  • 尝试添加“使用 System.Core;”
  • @KoViMa 你确定吗?
  • 您说“仅在 ​​Linq 中发生”但是我敢打赌,如果您这样做:var ints = new[] {1, 2, 3}; var twoOnly = ints.Where(i =&gt; i == 2); 那么我确定智能感知会正确显示吗?请尝试(在同一个源文件中);然后报告...

标签: c# linq linq-to-entities intellisense


【解决方案1】:

当模块中缺少对System.Data.Linq.dll 的引用时,通常会发生这种情况。

我敢打赌,您的数据上下文在另一个程序集中,其中引用设置正确(以便代码在编译时工作),但同时 Web 应用程序中缺少引用(因此 VS 不会显示智能感知)。

【讨论】:

  • 我的 web.config 中有这个:' '
  • 您的项目是网站还是网络应用程序?为什么需要两个参考(3.5 和 4.0)?
  • 它是网络应用程序。我不需要他们两个。可能是旧设置。所以我已经删除了它,现在我只有 4.0 版本,仍然是同样的问题
  • 您是否从项目树的 References 节点中添加了对 system.data.linq 的引用?
  • 我在项目树中没有引用节点:s18.postimage.org/zf3ta7ell/scrren.jpg">我的程序集如下所示:s13.postimage.org/l1limgo2f/222222.jpg">
【解决方案2】:

有时,EntityFramework 的引用可能会丢失。请确保您正在处理的项目中存在相同的内容。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-03-22
    • 1970-01-01
    • 2016-02-07
    • 2020-02-23
    • 2022-08-07
    • 2014-02-14
    • 2017-09-12
    • 2020-09-01
    相关资源
    最近更新 更多