2012-08-08 5 views
3

저는 저와 같이 질의를 작성하는 데 너무 열중하지 않습니다. 세 가지 엔티티의 정보가 들어있는 쿼리 개체를 만들려고합니다. 쿼리가 실행되면 EntityServerException이 처리되지 않았다고 알립니다. 특정 열을 끌어 오려면 DTO를 사용하고 있습니다. 나는 그 매개 변수 유형에 대한 GUID 받아 쓰기를 시도하고있는 쿼리 여기있다Linq to Entities Query가 실행에 실패했습니다.

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); } 
    } 
} 

: 그리고 여기

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. 
여기 내 기본 DTO이다

마치 내 모델에서 내 Dto를 찾으려고하는 것 같습니다 .edmx? 죄송합니다. 누구나 왜 내가이 예외를 얻었는지 알 수 있습니까? LINQPad에서이 쿼리를 사용하여 데이터를 다시 가져옵니다.

+0

당신이 구조와 유형에 대한 몇 가지 세부 사항을 줄 수를 참여한 프로젝트의 –

답변

1

나는 그것이 우리의 서버가 업데이트되지 함께 할 수있는 뭔가했다 생각,하지만 난 그렇게 같은 익명 형식 반환으로 극복 할 수 있었다 :

public List<LeadRestrictionsDto> GetLeadRestrictionListingNow(Guid id) 
    { 

     var 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 && (restriction.RestrictionId == 100 || restriction.RestrictionId == 200) && restriction.Active == true 
         select new 
            { 
             Modified = restriction.Modified, 
             RestrictionDescription = restriction.Description, 
             UserId = user.UserId, 
             LeadId = lead.LeadId, 
             FirstName = lead.FirstName, 
             Created = lead.Created, 
             LastName = lead.LastName 

            }; 


     return restrictions.ToList().Select(x=>new LeadRestrictionsDto() 
             { 
              Modified = x.Modified, 
              RestrictionDescription = x.RestrictionDescription, 
              UserId = x.UserId, 
              LeadId = x.LeadId, 
              FirstName = x.FirstName, 
              Created = x.Created, 
              LastName = x.LastName 
             }).ToList(); 


    }