我为我的 windowsphone 应用程序编写了一个数据服务,我正在尝试保存对此数据服务的更改。为此,我打电话BeginSaveChanges
:
Context.AddToMeasurements(temp);
Context.BeginSaveChanges(SaveChangesOptions.Batch, SaveChangesComplete, Context);
此函数的回调在调用时返回错误EndSaveChanges
。
private void SaveChangesComplete(IAsyncResult result)
{
// use a dispatcher to make sure the async void
// returns on the right tread.
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
DataServiceResponse WriteOperationResponse = null;
Context = result.AsyncState as MeasurementEntities;
try
{
WriteOperationResponse = Context.EndSaveChanges(result);
Debug.WriteLine("Batch State:");
Debug.WriteLine(WriteOperationResponse.BatchStatusCode);
}
catch (DataServiceRequestException ex)
{
Debug.WriteLine(ex.Message);
}
catch (InvalidOperationException ex)
{
Debug.WriteLine(ex.Message);
}
});
}
endsavechanges 返回的错误:
An exception of type 'System.Data.Services.Client.DataServiceClientException' occurred in Microsoft.Data.Services.Client.WP80.DLL and wasn't handled before a managed/native boundary
An exception of type 'System.Data.Services.Client.DataServiceRequestException' occurred in Microsoft.Data.Services.Client.WP80.DLL and wasn't handled before a managed/native boundary
A first chance exception of type 'System.Data.Services.Client.DataServiceRequestException' occurred in Microsoft.Data.Services.Client.WP80.DLL
An exception of type 'System.Data.Services.Client.DataServiceRequestException' occurred in Microsoft.Data.Services.Client.WP80.DLL and wasn't handled before a managed/native boundary
An error occurred while processing this request.
我想查看有关这些错误的一些更详细的信息,或者如果有人知道他们的意思也将受到赞赏,但是我如何在 Visual Studio 中完成(有关数据服务的更多详细信息)?
ps,我已经添加了:
config.UseVerboseErrors = true;
和
[ServiceBehavior(IncludeExceptionDetailInFaults = true)]
到我的数据服务。
请帮忙 :)
编辑:
当我删除 Try 构造并执行 EndSaveChanges 方法时。我可以阅读 innerExeptions,即:
当 IDENTITY_INSERT 设置为 OFF 时,无法在表“测量”中插入标识列的显式值。
任何想法是什么意思?