简体   繁体   中英

Is it possible to query all companies via ODATA in Dynamics Nav 2016

I've written the following code to query the ODATA endpoint in Dynamics Nav 2016. I did this by creating an ODATA connected service . I have passed a company name in the URL:

var navision = new Navision(
    new Uri("http://navision:7048/navision/OData/Company('Company1')"));

foreach (var foo in await navision.Foo.ExecuteAsync())
{
    Console.WriteLine(foo.Name);
}

Is it possible to query all companies in Navision? When I omit the /Company(...) section of the URL, I get an error:

DataServiceClientException: Cannot process the request because the default Microsoft Dynamics NAV company cannot be found. You can specify a default company in the service configuration file, or specify one for each tenant, or you can add a query string in the form of "company=[name]". You can see the available companies by accessing the default OData web service, Company. For more information, see "OData Web Services" in Help.

Different companies means physically different tables on SQL with names like [dbo].[CompanyName$TableName] . Nav will not do join for you. If you are using tenants the tables will be even in separate per tenant databases.

So you need to query each company and then combine acquired data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM