我正在尝试创建一个包含来自 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 中使用过这个查询,它可以毫无问题地拉回数据。