OdataClient SaveChanges 不起作用,结果为空 Microsoft.OData.Client.DataServiceResponse
OdataClient SaveChanges doesn't work and results an empty Microsoft.OData.Client.DataServiceResponse
因为一些扩展我封装了odata容器:
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);
}
}
当我使用我的 .dll(使用连接器 class)时,我得到一个空结果(statuscode = -1, no headers, ...)
这就是我调用 DLL 的方式
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
}
可能是因为我的 object 无效。但奇怪的是我没有看到任何验证发生...
关于如何传播 SaveChanges() 或 pre-validate(提交之前)实体有什么想法吗? post 没有发生(用 Fiddler 检查)
我的包装器 class 每次都创建一个新容器,因此实体已从 Default.Container
中删除
因为一些扩展我封装了odata容器:
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);
}
}
当我使用我的 .dll(使用连接器 class)时,我得到一个空结果(statuscode = -1, no headers, ...)
这就是我调用 DLL 的方式
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
}
可能是因为我的 object 无效。但奇怪的是我没有看到任何验证发生...
关于如何传播 SaveChanges() 或 pre-validate(提交之前)实体有什么想法吗? post 没有发生(用 Fiddler 检查)
我的包装器 class 每次都创建一个新容器,因此实体已从 Default.Container
中删除