Giter Site home page Giter Site logo

Comments (9)

texttechne avatar texttechne commented on June 27, 2024 1

Hi @erik-kers,

great detailed issue with sample repo! Kudos!

Ok, abstract entities shouldn't be that hard to accomodate for. Derived entity types work as demonstrated by your example with keys, so it's more like allowing keyless entity types. I just need to find the time.

I've prepared odata2ts for open types in the sense, that request and response may have additional properties. You won't get any exception and props are not filtered out or something. Of course, you have to take care of the typing yourself at that point by creatíng your own types based on the generated types... without metadata there's nothing odata2ts can do in this regard.

EntityType Without Keys by Virtue of Being an Open Type

However, I have problems to understand how expandos should work without keys when they are declared as EntityType. Hence, I think that this example is simply wrong:

              <EntityType Name="OpenBaseEntity" OpenType="true" />

              <EntityType Name="DynamicObject" BaseType="ExampleModel.OpenBaseEntity">
                <Key>
                    <PropertyRef Name="Id" />
                </Key>
                <Property Name="Model" Type="Edm.String" />
                <Property Name="Year" Type="Edm.Int32" />
            </EntityType>

The main difference between EntityType and ComplexType is that the former requires a key while the latter does not. Only by declaring the EntityType as abstract you don't have to specify the key. See this explanation by Microsoft:

First, some OData terminology:

Entity type: A structured type with a key.
Complex type: A structured type without a key.
Open type: A type with dynamic properties. Both entity types and complex types can be open.

Imagine you would expose the OpenBaseEntity as EntitySet. You won't be able to address a specific entity by id, because the key isn't known: OpenBaseEntity(???). I think implementation-wise that the key must be known at compile time and cannot be used dynamically at runtime.

Additional reading: Open Types explained by odata.org

Conclusion

So this issue boils down to allowing abstract types, right? Or do you have a specific problem with expandos?

from odata2ts.

erik-kers avatar erik-kers commented on June 27, 2024

Hi @texttechne

I'm sorry about the late reply. I've been trying to get ahold of a real metadata-document but it doesn't seem like I will be able to do this.

You are correct in that I've made an error regarding the OpenType. I will instead give you the real example with expando.

<Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="Microsoft.Dynamics.CRM" Alias="mscrm">
<EntityType Name="crmbaseentity" Abstract="true"/>
<EntityType Name="expando" BaseType="mscrm.crmbaseentity" OpenType="true"/>

As you can see it has tyhe crmbaseentity as it's base type. And there are no other types using it as the base type. I don't know how I got that messed up tbh.

[edit: removed some irrelevant stuff]

So in summary, yes. the issue boils down to allowing types.

from odata2ts.

nickcomua avatar nickcomua commented on June 27, 2024

I'm also tried this for Microsoft Datavers. Had same issue.

Starting generation process
Found metadata file at:  resource/trippin.xml   
Reading metadata from file: resource/trippin.xml
Error while running the program Error: Key property is missing from Entity "crmbaseentity" (crmbaseentity)!

from odata2ts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.