oData client limit classes

581 views Asked by At

I am currently testing oData client in combination with Dynamics AX 7. The metadata file coming from AX is over 900'000 lines big and if i use the default oData client and auto generate a C# class file it won't build because of too many string literals (.net error).

Now i'm looking for a way to tell the client generator which classes to generate (by entity name for example) and which not (about 95% isn't needed on the client-side).

Sadly limiting the metadata on AX side is not an option.

2

There are 2 answers

1
Ronald Rink 'd-fens' On BEST ANSWER

We had a similar issue, where we had to modify the available $metadata information from an ODATA service. In our case we used the DataServiceContext generator and pointed to the original server URI but used Fiddler as a Proxy inbetween. By using a breakpoint in Fiddler we could serve our modifed $metadata xml to the DataServiceContext generator in Visual Studio. Works fine when you used sparingly and if the API is stable.

1
BateTech On

Yes using VS2015 will solve your "too many strings" error, but you will still have a problem where Visual Studio 2015 will crash if you open the huge file that is generated or accidentally step into the oData client file while debugging.

To get around this issue, I edited the T4 templates which auto-generate the oData client classes so that they create multiple files, so you do not end up with one huge 1 million+ line file. Using the updated T4 templates, it will generate the same code, but will split into a new file every 5MB.

The updated T4 templates can be found here: https://github.com/batetech/D365FO-oData-T4-MultiFile-Templates