OData / ODataConnectedService

A Visual Studio extension for generating client code for OData Services
Other
79 stars 41 forks source link

Unable to select single Schema Type #404

Open blycolin-dev opened 1 month ago

blycolin-dev commented 1 month ago

Describe the bug

When selecting a single schema type, a lot more are added. In my example Dynamics 365 Operations odata metadata selected in address.

Default all 5970 are selected First deselect all Then select for example AbsenceCode, then an additional 2551 are also selected.

Ofcourse creating too many code. I only wanted one.

A few are single selectable but most not.

Version of the Project affected

ODataConnectedService v1.1.0 VisualStudio Version v17.10.4

Expected behavior

Single entity selection schematype

gathogojr commented 1 month ago

Thank you @blycolin-dev for reaching out to us. You would observe the behaviour if the AbsenceCode schema type is has a dependency on the schema types that are being auto-selected. Please confirm if the schema types are dependent one another.

wandeg commented 1 month ago

https://learn.microsoft.com/en-us/odata/connectedservice/choosing-what-to-generate image

blycolin-dev commented 1 month ago

Hi, thanks for your comments.

I find it hard to believe there are so many depended entites.

In Dynamics i can get the data from Customers by entering just this URL , for ex. : https://usnconeboxax1aos.cloud.onebox.dynamics.com/data/CustomerV3

I can see the same CustomerV3 entity in the ODATA schema type selection. So I would like to be able to just only select this CustomerV3.

I just tested to select the CustomerV3 with the odataconnectserice, and I see that that, maybe coincidence, but again 2552 selected. Some more customer related but also for ex. ProductSize , ProductCategory and SalesOrder and so on.

Can imagine that there are relations between all those enities , but where I connect to the ODATA with for ex. PowerBI I can perfectly connect to the CustomerV3 without having to select any other.

It would be great to be able to do the same with this connector.

Thanks.

habbes commented 1 month ago

@blycolin-dev it would be hard to tell without having access to the actual schema whether what you're experience is existing behaviour or a bug. Without having any concrete example we can't rule out the possibility that the CustomerV3 entity has direct or indirect dependencies to seemingly unrelated types like ProductSize, etc. For example, if CustomerV3 entity has a "Orders" navigation property of type Order, which in turn happens to have a property of type SalesOrder and a navigation property Products of some type ProductOrder with properties of types ProductSize and ProductCategory, then CustomerV3 transitively has dependencies to ProductCategory and ProductSize. Could you verify whether a scenario like this does not occur in your schema?

If such dependencies exist, then OData Connected Service will automatically include those types. If it does not, then the generated code will not compile because CustomerV3 will be generated with a reference to a type which does not exist in the code. Currently when selecting a type, all its properties will be generated, we don't provide a way to selectively exclude properties of a type.

Does the PowerBI connector that you referred to also generate client code? I would be interesting in seeing the code it generates for such a scenario and how it prevents issues related to missing dependencies.

If on the other hand types that depend on CustomerV3 (e.g. types that have a reference to CustomerV3) but that CustomerV3 does not depend on are also included, then this would be a bug.

lucacivale commented 1 month ago

This is indeed working as designed. We also work with a Dynamics 365 endpoint and the entities have indirect dependencies through relations. Due to the size of the endpoint it is nearly impossible to use the extension and Dynamics 365 implemented some workarounds. You either have to manipulate/trim the metadata document and pass it to the extension or fork the repro and disable the auto selection of related types. I already opened issue #303. The issue isn't up to date and some other changes must be done as well. I can assist with the implementation if this is considered for the product.

habbes commented 1 month ago

@lucacivale thanks for contributing to this thread. What kind of product changes would you suggest to handle issues related to such large dependency graphs? I assume it would require excluding properties that lead that refer to unselected types?

blycolin-dev commented 1 month ago

@lucacivale @habbes Thanks for your help and suggestions. Yes, working as designed ,leading to select so many entities makes it too complex (for me atleast ;-) ) and slow also.

Maybe it is possible to see the depend entities as "suggestions" but not being forced to select them.

I know that if I want Customer data with my SalesOrderheaders I have to select them both, if I want SalesorderLines that one too and so on. But if I only what a very simple list of Customer numbers and names, i do not have to know anything about Salesorder/Project/HRM entities or types.

lucacivale commented 1 month ago

@blycolin-dev since we want the same change I think we should close this issue and continue the discussion on #303 since there is already some documentation.

blycolin-dev commented 1 month ago

Ok let do that! Thanks.