我正在尝试创建一个查询对象,其中包含来自3个不同实体的信息。当查询执行时,它告诉我发生了一个 EntityServerException 未处理的异常。我使用DTO来获取特定列。以下是我的基本DTO:
public class LeadRestrictionsDto : BasicModelBase
{
private Guid _userId;
private Guid _leadId;
private string _restrictionDescription;
private DateTime? _modified;
[Key]
public Guid UserId
{
get { return _userId; }
set { SetValueAndNotify(() => UserId, ref _userId, value); }
}
public Guid LeadId
{
get { return _leadId; }
set { SetValueAndNotify(() => LeadId, ref _leadId, value); }
}
public string RestrictionDescription
{
get { return _restrictionDescription; }
set { SetValueAndNotify(() => RestrictionDescription, ref _restrictionDescription, value); }
}
public DateTime? Modified
{
get { return _modified; }
set { SetValueAndNotify(() => Modified, ref _modified, value); }
}
}
这里是我试图编写的查询,它接受一个GUID作为参数类型:
public List<LeadRestrictionsDto> GetLeadRestrictionListingNow(Guid id)
{
IEnumerable<LeadRestrictionsDto> restrictions = from user in Manager.Users
join lead in Manager.Leads on user.UserId equals lead.OriginalOwnerId
join restriction in Manager.UserRestrictionListings on user.UserId equals restriction.UserId
where user.UserId == id
select new LeadRestrictionsDto
{
Modified = restriction.Modified,
RestrictionDescription = restriction.Description,
UserId = user.UserId,
LeadId = lead.LeadId
};
List<LeadRestrictionsDto> userRestiction = restrictions.ToList(); //Exception occurs here
return userRestiction;
}
这是我得到的确切异常:
Unable to locate type: System.Linq.IQueryable`1[[Prime.Library.Repository.LeadRestrictionsDto, Prime.Library, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089. Check that the assembly holding this type is available in the bin/exe folder. Also check that both your assemblies and DevForce assemblies have the expected version number on both client and server.
似乎它正在尝试在我的model.edmx中找到我的Dto?如果这听起来很无知,我很抱歉。有人有想法为什么会出现这个异常吗?我已经在LINQPad中尝试了这个查询,并且没有任何问题地返回数据。