我有一个针对我的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)]
到我的dataservice。
请帮助:)
编辑:
当我删除Try构造并执行EndSaveChanges方法时。我可以阅读innerExeptions,它是:
当IDENTITY_INSERT设置为OFF时,无法在表'Measurement'中为identity列插入显式值。
任何想法是什么意思?
答案 0 :(得分:1)
当IDENTITY_INSERT设置为OFF时,无法在表'Measurement'中为identity列插入显式值。
这意味着您没有将任何值传递给Measurement
列,它是数据库中的必填字段。你需要传递价值。