Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/301.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 返回实体框架中的所有IQueryable_C#_Entity Framework - Fatal编程技术网

C# 返回实体框架中的所有IQueryable

C# 返回实体框架中的所有IQueryable,c#,entity-framework,C#,Entity Framework,我刚从Linq切换到entities框架,返回“所有行”的方法出现了问题。我得到:“类型‘System.Data.Objects.DataClasses.EntityObject’在调用数据层的“服务层”中的“未引用的程序集中定义”错误 我在以下方面出错: BookingObjectRepository _repository = new BookingObjectRepository(); public IQueryable<BookingObject> GetBookingOb

我刚从Linq切换到entities框架,返回“所有行”的方法出现了问题。我得到:“类型‘System.Data.Objects.DataClasses.EntityObject’在调用数据层的“服务层”中的“未引用的程序集中定义”错误

我在以下方面出错:

BookingObjectRepository _repository = new BookingObjectRepository();

public IQueryable<BookingObject> GetBookingObjects()
{
    return _repository.GetBookingObjects();
}
BookingObjectRepository\u repository=new BookingObjectRepository();
公共IQueryable GetBookingObjects()
{
返回_repository.GetBookingObjects();
}
在“数据层”,我有:

bookingsystementies\u entities=newbookingsystementies();
公共IQueryable GetBookingObjects()
{
从bo返回_entities.BookingObjectSet
选择bo;
}
更新:过滤器项,它们“物理”在过滤器文件夹中,但名称空间与emdx文件使用的名称空间相同

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; 

namespace BookingSystem.Data.Models
{

public static class BookingObjectFilters
{public static IQueryable<BookingObject> ByBookingObjectID(this IQueryable<BookingObject> qry, int bookingobjectID)
{
return from bo in qry
               where bo.BookingObjectID == bookingobjectID
               select bo;
}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用系统文本;
命名空间BookingSystem.Data.Models
{
公共静态类BookingObject筛选器
{公共静态IQueryable ByBookingObjectID(此IQueryable qry,int bookingobjectID)
{
在qry从bo返回
其中bo.BookingObjectID==BookingObjectID
选择bo;
}
您有

using System.Data;
using System.Data.Objects.DataClasses;
在你的使用中

应该是

public IQueryable<BookingObject> GetBookingObjects() { return _repository.GetBookingObjects(); } 
public IQueryable GetBookingObjects(){return\u repository.GetBookingObjects();}
希望有帮助

丹,你有吗

using System.Data;
using System.Data.Objects.DataClasses;
在你的使用中

应该是

public IQueryable<BookingObject> GetBookingObjects() { return _repository.GetBookingObjects(); } 
public IQueryable GetBookingObjects(){return\u repository.GetBookingObjects();}
希望有帮助


Dan

您的系统必须安装.NET 3.5 SP 1或更高版本,您的项目必须引用system.Data.Entity程序集(查看解决方案资源管理器中的“引用”节点)。

您的系统必须安装.NET 3.5 SP 1或更高版本,您的项目必须引用system.Data.Entity程序集(查看解决方案资源管理器中的“引用”节点).

我应该在哪里添加它?在我的数据层存储库中?检查编辑先生,注意到方法签名有问题BookingObject在哪个名称空间中?除了edmx文件中的designer文件之外,没有定义任何名称空间。我应该在哪里添加它?在我的数据层存储库中?检查编辑先生,注意到方法签名有问题在命名空间中是否有BookingObject?除了在edmx文件中的设计器文件中,没有定义任何对象