3

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 でこのクエリを試してみたところ、問題なくデータが返されました。

4

1 に答える 1

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


  }
于 2012-08-09T20:30:34.000 に答える