无法评估表达式。操作不受支持。未知错误:0x80070057。使用Linq

时间:2018-05-31 12:59:03

标签: c# entity-framework linq

我试图访问我的SQL数据库来检索我的数据。

public projecta100333EntitiesEntities1 Entity { get; set; }

        public ConnectionClass()
        {
            Entity = new projecta100333EntitiesEntities1();
        }

我在与数据库连接时遇到此错误:

  

函数评估需要运行所有线程   Image of error when connecting to database

当我重新加载错误以查看错误时,我得到数据库中表的Count为0,而实际上我有15个。

当我继续使用LINQ从数据库获取数据时:

   public IQueryable<All_Articles> GetArticles()
        {

            var list = Entity.All_Articles; 
            return list;
        }

返回类型相同:

  

函数评估需要运行所有线程

但是这次当我重新加载错误时,我收到了这个新错误:

  

无法评估表达式。操作不受支持。未知   错误:0x80070057。

数据库和Visual Studio之间的连接是使用实体模型完成的。实体模型连接正确,因为表格是可视化显示的,当我更新它们时,它们会成功更新。

App.config和web.config中的连接字符串与正确的实体相同:

<add name="projecta100333EntitiesEntities1" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=USER\SQLEXPRESS;initial catalog=projecta100333Entities;integrated security=True;multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient" />

1 个答案:

答案 0 :(得分:0)

请参阅此。只是改变     返回清单; 至     返回list.ToList();

Entity Framework is throwing an error "Unable to evaluate the expression. Operation not supported. Unknown error: 0x80070057."