我一直在尝试从微软的 odata 客户端运行 NAV 功能(Microsoft Dynamics 365 Business Central)。当我创建一个 odatav4 数据源并导入$metadata时,我能够在自动生成的代码中包含 codeunits 函数,这为我创建了一个 DataServiceActionQuery 类型:
/// <summary>
/// There are no comments for Funcions_TestFunction in the schema.
/// </summary>
[global::Microsoft.OData.Client.OriginalNameAttribute("Funcions_TestFunction")]
public virtual global::Microsoft.OData.Client.DataServiceActionQuery Funcions_TestFunction(string param1, string param2, string param3)
{
return new global::Microsoft.OData.Client.DataServiceActionQuery(this, this.BaseUri.OriginalString.Trim('/') + "/Funcions_TestFunction", new global::Microsoft.OData.Client.BodyOperationParameter("param1", param1),
new global::Microsoft.OData.Client.BodyOperationParameter("param2", param2),
new global::Microsoft.OData.Client.BodyOperationParameter("param3", param3));
}
当我尝试运行它时,我必须将公司代码传递给它,但我不知道该怎么做:
Uri texte = new Uri(@"http://192.168.0.18:18148/Instancename/ODataV4/");
NAV.NAV x = new NAV.NAV(texte);
x.Credentials = credentials;
DataServiceActionQuery funcionini = x.Funcions_TestFunction(param1, param2, param3);
funcionini.Execute();
使用 DataServiceQuery (发布的页面)我没有问题通过它,只需添加查询选项:
DataServiceQuery<NAV.Customer> z = x.Customer.AddQueryOption("company", "Mycompany");
IEnumerable<NAV.Customer> resultat = z.Where(f => f.Type == "something").OrderBy(f => f.Name);//.GetAllPages();