相关疑难解决方法(0)

ASP.NET实体框架NotSupportedException

我在我的应用程序的数据层中使用LINQ to Entities,但是在调用results.ToList()时遇到了NotSupportedException.这是导致异常的函数:

    public List<Organization> GetByLocation(Location l)
    {
        using (Entities entities = new Entities())
        {
            var results = from o in entities.OrganizationSet
                          where o.Location == l
                          select o;

            return results.ToList<Organization>();
        }
    }
Run Code Online (Sandbox Code Playgroud)

关键是将给定位置的所有组织的列表返回到服务层(将其返回给MVC控制器,MVC控制器将其转换为JSON,然后将其返回给客户端).服务层期望返回List.

这可能很简单......任何帮助?

c# asp.net linq-to-entities

2
推荐指数
1
解决办法
463
查看次数

标签 统计

asp.net ×1

c# ×1

linq-to-entities ×1