Asp.net web api OdataClient SaveChanges不';无法工作,结果为空的Microsoft.OData.Client.DataServiceResponse
由于一些扩展,我封装了odata容器:Asp.net web api OdataClient SaveChanges不';无法工作,结果为空的Microsoft.OData.Client.DataServiceResponse,asp.net-web-api,entity-framework-6,odata,asp.net-web-api2,odatacontroller,Asp.net Web Api,Entity Framework 6,Odata,Asp.net Web Api2,Odatacontroller,由于一些扩展,我封装了odata容器: public class Connector { public string apiKey{get;set;} public Connector(string apiKey) { this.apiKey = apiKey; } public Default.Container Get() { Default.Container container = new Defaul
public class Connector
{
public string apiKey{get;set;}
public Connector(string apiKey)
{
this.apiKey = apiKey;
}
public Default.Container Get()
{
Default.Container container = new Default.Container(new Uri("http://documents.omnisoftonline.be/odata"));
container.BuildingRequest += container_BuildingRequest;
return container;
}
/// <summary>
/// When fetching a single Document, you can enable this method to including fetch the binary data
/// </summary>
/// <param name="container"></param>
/// <returns></returns>
internal bool doIO = false;
internal void container_BuildingRequest(object sender, BuildingRequestEventArgs e)
{
e.Headers.Add("X-ApiKey", apiKey);
if (doIO && e.RequestUri.ToString().Contains("/Documents"))
{
e.RequestUri = new Uri(e.RequestUri.ToString() + (e.RequestUri.Query.Contains("?") ? "&" : "?") + "doIO=true");
}
this.container_BuildingRequest(sender, e);
}
}
可能是因为我的对象无效。但奇怪的是,我没有看到任何验证发生
关于如何传播SaveChanges()或预验证(提交前)实体,您有什么想法吗?帖子没有发生(通过Fiddler检查)我的包装器类每次都创建了一个新容器,因此实体从默认容器中删除。容器我的包装器类每次都创建了一个新容器,因此实体从默认容器中删除。容器FirstOrDefault工作(获取实体):var docToShow=documentsConnector.Get().Documents.Where(el=>el.Id==options.key.Value).FirstOrDefault();我注意到System.ComponentModel.INotifyPropertyChanged属性未激发。。。如果它有助于与FirstOrDefault交叉引用(获取实体):var docToShow=documentsConnector.Get().Documents.Where(el=>el.Id==options.key.Value).FirstOrDefault();我注意到System.ComponentModel.INotifyPropertyChanged属性未激发。。。如果它能与
documentsConnector.Get().AddToDocuments(docToCreate);
var serviceResponse = documentsConnector.Get().SaveChanges(Microsoft.OData.Client.SaveChangesOptions.None); //tried several options
foreach(var operationResponse in serviceResponse)
{
Console.WriteLine("Response: {0}", operationResponse.StatusCode); //no operationResponses, so this isn't executed
}