프로젝트 설정이 있습니다. ASP.Net 사이트에서 호스팅되는 Silverlight 클라이언트 응용 프로그램입니다. ADO.Net Entity Framework는 SQL Server 데이터베이스 및 통신을위한 ADO.Net 데이터 서비스와 통신합니다. 내 데이터베이스에서 작동하도록 비동기 CRUD Silverlight 삽입을 가져 오는 데 문제가 있습니다. 첫 번째 메소드는 잘 작동하여 URI를 전달합니다. 그러나 "OnClientJobQueryComplete"메서드가 실행되면 약 5 줄의 줄이 끊어지며 이유를 이해할 수 없습니다. 예외는 "이 요청을 처리하는 동안 오류가 발생했습니다."라고 말합니다. Silverlight - Crud Insert가 예기치 않게 실패 했습니까?
private void addStuff_Click(object sender, RoutedEventArgs e)
{
// Define a URI that returns the product with the specified ID.
Uri jobrefUri = new Uri(svcContext.BaseUri.AbsoluteUri
+ "/ClientJob(" + this.jobref.Text + ")");
// Begin a query operation retrieve the Product object
// that is required to add a link to the new Order_Detail.
svcContext.BeginExecute<ClientJob>(jobrefUri,
OnClientJobQueryCompleted,null);
}
private void OnClientJobQueryCompleted(IAsyncResult result)
{
// Use the Dispatcher to ensure that the
// asynchronous call returns in the correct thread.
Dispatcher.BeginInvoke(() =>
{
// Get the Product returned by the completed query.
IEnumerable<ClientJob> queryResult =
svcContext.EndExecute<ClientJob>(result);//**TRIES THIS BUT FAILS HERE
ClientJob returnedClientJob = queryResult.First();
// Get the currently selected order. (Create new Guid since not Northwind)
Guid g = Guid.NewGuid();
// Create a new Order_Details object with the supplied FK values.
Job newItem = Job.CreateJob(g);
//Job newItem = Job.CreateJob(g, returnedClientJob.JobRef);
jobsBindingCollection.Add(newItem);
// Add the new item to the context.
svcContext.AddToJob(newItem);
//// Add the relationship between the order and the new item.
//currentOrder.Order_Details.Add(newItem);
//svcContext.AddLink(currentOrder, "Order_Details", newItem);
//// Set the reference to the order and product from the item.
//newItem.Orders = currentOrder;
//svcContext.SetLink(newItem, "Orders", currentOrder);
// Add the relationship between the product and the new item.
returnedClientJob.Job.Add(newItem);
svcContext.AddLink(returnedClientJob, "Job", newItem);
// Set the reference to the product from the item.
newItem.ClientJob = returnedClientJob;
svcContext.SetLink(newItem, "ClientJob", returnedClientJob);
}
);
}
이 코드
은 해제하고 Northwind 데이터베이스를 사용 this 마이크로 소프트 튜토리얼에서 수정됩니다. 튜토리얼의 다른 코드 샘플은 모두 데이터베이스가 Northwind와 비슷한 구조이므로 잘 작동합니다. 지금까지 RUD를 구현할 수 있었지만 CRUD는 구현할 수 없었습니다.피사체를 밝힐 사람이 있습니까?
대단히 감사합니다.
이 하나가 이미 두려워 메신저 봤어, – Goober