shashisadasivan / EDMXTrimmer

D365 Finance and operations EDMX trimmer
MIT License
21 stars 12 forks source link

Keep relations #23

Closed FH-Inway closed 1 year ago

FH-Inway commented 1 year ago

@AndreasHassing mentioned in https://github.com/OData/ODataConnectedService/issues/327#issuecomment-1591368666 that relations are not kept in the trimmed file.

To avoid an off topic discussion in that issue, this issue was created to continue the discussion here.

The discussion so far:

@FH-Inway https://github.com/OData/ODataConnectedService/issues/327#issuecomment-1591015472

For trimming down huge ERP OData endpoints (and specifically Dynamics 365 FO), take a look at https://github.com/shashisadasivan/EDMXTrimmer

@AndreasHassing https://github.com/OData/ODataConnectedService/issues/327#issuecomment-1591368666

That's really cool, except that it doesn't keep relations which are very useful artifacts for certain complicated applications using the OData schema for code generation.

Edit: their code could be altered to include relations, while that increases the complexity quite a bit.

@FH-Inway https://github.com/OData/ODataConnectedService/issues/327#issuecomment-1591559538

@AndreasHassing Do you mean the NavigationProperty tags under the EntityType?

@AndreasHassing https://github.com/OData/ODataConnectedService/issues/327#issuecomment-1591633918

That's right.

FH-Inway commented 1 year ago

@AndreasHassing Hope it's ok to continue this discussion here.

So the NavigationProperty tags under the EntityType are kept by EDMXTrimmer if the entity that is referenced by the navigation link is also part of the trimmed file. Would that work for you? Or do you need relations that point to entities that are not part of the trimmed edmx?

A change for that would be simple, we would just introduce a new argument that would prevent the following part of the trimming logic from executing. However, I'm not sure if the resulting file would still be valid. E.g. could ODataConnectedService still generate a compileable C# client from it? And if so, how would that client behave if a link to an entity is called where the entity does not exist in the client?

https://github.com/shashisadasivan/EDMXTrimmer/blob/bc6354078dfafdaf76d34e932235650bfa34ff1c/EDMXTrimmer/EDMXTrimmer/EdmxTrimmer.cs#L162-L165

AndreasHassing commented 1 year ago

@AndreasHassing Hope it's ok to continue this discussion here.

So the NavigationProperty tags under the EntityType are kept by EDMXTrimmer if the entity that is referenced by the navigation link is also part of the trimmed file. Would that work for you? Or do you need relations that point to entities that are not part of the trimmed edmx?

A change for that would be simple, we would just introduce a new argument that would prevent the following part of the trimming logic from executing. However, I'm not sure if the resulting file would still be valid. E.g. could ODataConnectedService still generate a compileable C# client from it? And if so, how would that client behave if a link to an entity is called where the entity does not exist in the client?

https://github.com/shashisadasivan/EDMXTrimmer/blob/bc6354078dfafdaf76d34e932235650bfa34ff1c/EDMXTrimmer/EDMXTrimmer/EdmxTrimmer.cs#L162-L165

Oh really? From peeking at the readme and code, it looked like you always remove navigation links, regardless of whether the linked-to entity is in the list of entities to keep.

That is not how it works, it sounds like?

AndreasHassing commented 1 year ago

Yeah I see now. You have a Where which only finds links to entities that haven't been chosen. My bad!

FH-Inway commented 1 year ago

@AndreasHassing Not at all and thanks for the feedback. I will close this issue, but feel free to post further questions or comments (or open a new issue).