0

SL5 + EF + WCF アプリでこの Web サービス エラーが発生することがあります。

「ドメイン操作エントリ 'AddUserPresentationModelToRole' のパラメーター 'role' は、定義済みのシリアル化可能な型の 1 つである必要があります。」

これは同様のエラーですが、彼の解決策は私にはうまくいきません。

データベース エンティティをクライアントに表示する codegenned DomainService があります。

 [EnableClientAccess()]
public partial class ClientAppDomainService : LinqToEntitiesDomainService<ClientAppUserEntitlementReviewEntities>
{

    public IQueryable<Account> GetAccounts()
    {
        return this.ObjectContext.Accounts;
    }
    //..etc...

そして、プレゼンテーション モデルと db エンティティを表示するカスタム サービスです。

[EnableClientAccess]    
[LinqToEntitiesDomainServiceDescriptionProvider(typeof(ClientAppUserEntitlementReviewEntities))]
public class UserColourService : DomainService
{

    [Update(UsingCustomMethod = true)]
    public void AddUserPresentationModelToRole(UserPresentationModel userPM, Role role, Reviewer reviewer)
    {
        ...
    }

    public IDictionary<long, byte> GetColourStatesOfUsers(IEnumerable<RBSUser> listOfUsers, string adLogin) 
    {
        //....
    }
}

およびプレゼンテーションモデル:

public class UserPresentationModel
    {
        [Key]
        public long UserID { get; set; }

        public byte UserStatusColour { get; set; }

        public string MessageText { get; set; }

        [Include]
        [Association("asdf", "UserID", "UserID")]
        public EntityCollection<Account> Accounts { get; set; }

        public DateTime AddedDate { get; set; }

        public Nullable<long> CostCentreID { get; set; }

        public DateTime? DeletedDate { get; set; }

        public string EmailAddress { get; set; }

        public long EmployeeID { get; set; }

        public string FirstName { get; set; }

        public Nullable<bool> IsLeaver { get; set; }

        public string LastName { get; set; }

        public DateTime LastSeenDate { get; set; }

        public string LoginDomain { get; set; }

        public string LoginName { get; set; }

        public byte WorldBuilderStatusID { get; set; }

    }

また、ソリューションを確実に失敗させることもできません。サービスを少し変更する、つまり再コンパイルするたびに、すべてが機能するようです。

RIAServices が手作りの DomainService でサポートしていない型 - LinqToEntitiesDomainServiceDescriptionProvider を使用して手作りのサービスをデコレートすることは、同じことを言っているようです。

4

1 に答える 1

0

ここで考えられる答えは、結果とともにここ にも投稿されます。

Colin Blairから:これまでに機能することに少し驚いています。以前、名前付きの更新に追加のエンティティを渡そうとしている人を見たことがないと思います。まったく機能しているのは、RIAサービスのバグである可能性があります。何を達成しようとしていますか?

ちなみに、ObjectContextは正しく破棄されないため、メモリリークが発生します。LinqToEntitiesDomainSerivceを使用していない理由はありますか?ObjectContextの存続期間を管理します。

結果:

1)これは理にかなっています。より賢明なパラメータ(int /文字列)にリファクタリングされ、すべてが機能しています。

2)LinqToEntitiesDomainSerivceを使用する1つのサービスに3つの別々のサービスをまとめました。以前に分割した理由は、PresentationModelでCustomUpdateを使用しても機能しないという想定でした。代わりに、DomainServiceを継承する必要がありました。私はメソッドを作成することでこれを回避しました:

// need this to avoid compile errors for AddUserPresentationModelToRole.. should never be called
public IQueryable<UserPresentationModel> GetUserPresentationModel()
{
    return null;
}
于 2013-01-15T17:09:35.223 に答える