Windows Phone 7에서 WCF 데이터 서비스를 사용하고 있습니다. 한 번 클릭하여 관계형 데이터를 저장하고 싶습니다. 어떻게해야합니까?wcf 데이터 서비스가 한 번의 클릭으로 관계형 데이터 저장
그것은 생각의 2 테이블 : 종류와 제품
I 데이터 UI를 저장할:
Cateogry 표에서: -
카테고리 ID : (자동 증가)
범주 : ABC제품에서 표 : -
ProductId :-(자동 증가)
카테고리 ID : -? 저장을 클릭 버튼을
XYZ :
내가 충당 테이블의 데이터 위에 삽입 할, 내가 그걸 어떻게 할 수
ProductsName을 (확실하지가 어떻게 검색 할 수 있습니다)? 하나 개의 테이블에 데이터 추가에 대해 나는 다음과 같은 코드를 사용하고
: 하나로, OData 관계에서
try
{
context = new NorthwindEntities(NorthwindUri);
context.AddToProducts(product);
context.BeginSaveChanges(new AsyncCallback((result) =>
{
bool errorOccured = false;
// Use the Dispatcher to ensure that the
// asynchronous call returns in the correct thread.
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
context = result.AsyncState as NorthwindEntities;
try
{
// Complete the save changes operation and display the response.
DataServiceResponse response = context.EndSaveChanges(result);
foreach (ChangeOperationResponse changeResponse in response)
{
if (changeResponse.Error != null) errorOccured = true;
}
if (!errorOccured)
{
MessageBox.Show("The changes have been saved to the data service.");
}
else
{
MessageBox.Show("An error occured. One or more changes could not be saved.");
}
}
catch (Exception ex)
{
// Display the error from the response.
MessageBox.Show(string.Format("The following error occured: {0}", ex.Message));
}
});
}), context);
}
catch (Exception ex)
{
MessageBox.Show(string.Format("The changes could not be saved to the data service.\n"
+ "The following error occurred: {0}", ex.Message));
}