2012-03-02 5 views
0

私はコレクションに追加すると上の変更を送信する方法で、ビューモデルでコレクションに追加することができるよ:RIA ServicesとEntity Frameworkを使用してエンティティコレクションをデータベースに保存するにはどうすればよいですか?

public void AddEntityDetail() 
    { 
     this.IsBusy = true; 
      this.entityContext.SubmitChanges(OnSubmitChangesCompleted, null); 
    } 

    public void AddEntityCollection(EntityDetail entityDetail) 
    { 
     if (!this.entityDetailContext.EntityDetails.Contains(entityDetail)) 
      this.entityDetailContext.EntityDetails.Add(entityDetail); 

    } 

私は現在、サービスかかわらず、これを渡す方法がわかりませんそれをデータベースに追加します。 また、このエンティティはxamlにバインドされていません。

+1

:私の以前の回答を言い換えする

。 SubmitChangesメソッドはそれを行います。 xamlでのバインディングやバインディングも何も影響しません。 –

答えて

0

WCF RIA Servicesの全ポイントは、データ転送を隠すことです。

データセットに対してCRUD操作を行い、SubmitChanges()を呼び出します。 SubmitChangesはチェンジセット(作成された一連の変更)を作成し、それらをサーバーに転送します。

サーバー側は、すべての変更が処理されるまで、メソッドを順番に呼び出して、さまざまなRIAサーバーCRUDメソッドを各オブジェクトタイプに対して呼び出します。メソッドは、パラメータと戻り値の型と一致します。あなたがサービスに何かを渡す必要はありません

On the receiving side it goes through all the changes and says: 

Q. "Is this an object deletion?" 
A. Yes... 
Q. "What object type is it?" 
A. BlahBlah 
Q. "Do we have a method called Delete that takes a BlahBlah parameter?" 
A. Yes... 
It then calls that method with the object from the changeset 

Rinse and repeat for all other changes. 
関連する問題