2012-03-02 1 views
0

:RIA 서비스 및 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.