我试图访问我的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="data source=USER\SQLEXPRESS;initial catalog=projecta100333Entities;integrated security=True;multipleactiveresultsets=True;application name=EntityFramework"" providerName="System.Data.EntityClient" />
答案 0 :(得分:0)
请参阅此。只是改变 返回清单; 至 返回list.ToList();