How can we improve Breeze.js?

Support inheritence in the object model

233 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Jay TrabandJay Traband shared this idea  ·   ·  Admin →

    19 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • Ward BellWard Bell commented  · 

        @Anonymous - Don't know what you mean. Should work for any query, including `fetchEntityByKey`. Please post a prospective bug report on StackOverflow rather than User Voice; and please provide details so that we can repro. Thx.

      • JeremyJeremy commented  · 

        Does this work for manager.fetchEntityByKey? Only seems to be pulling in fields from the base class when I inspect json traffic.

      • PeterPeter commented  · 

        Great! I'll follow this up at Stackoverflow.

        Thanks again!

      • PeterPeter commented  · 

        Wow! Amazing how quickly you guys answered to this petition! Thanks a lot for this quick response!

        However, trying out this new version of Breeze, we've hit a problem here. When trying to load the metadata, we get this error:

        "Error: Metadata import failed for api/securitychart/Metadata; Unable to process returned metadata:Unable to locate a 'Type' by the name: Vehicle:#Project.Model.Entities"

        Just for clarification, the entity "Vehicle" is the base type from which two other entities "Motorbike" and "Car" inherit.

        We've digged up a bit through breeze's code and found that the JSON returned from the ContextProvider.Metadata() method returns the array of entityTypes in the following order:
        [0]: Motorbike
        [1]: ...
        [2]: ...
        [3]: Vehicle
        [4]: Car

        And the error pops out when trying to parse then entity data for Motorbike.

        Without having much idea what was going on, we guessed that the base class Vehicle was not available when trying to parse the metadata for Motorbike, so we manipulated the array to let it process first the base class Vehicle. After doing this, this error no longer appears, but there's a different one "bad navigation properties".

        You think you guys could give us some clue about how to proceed from here?

        Thank you very much for your effort!

      • Ward BellWard Bell commented  · 

        @Martin Klemsa - Potentially good idea. because THIS particular User Voice item is close, please open a new UserVoice for this request.

        I assume you mean that the developer should be able to add a custom JavaScript validator to the metadata for a property of the base class (or the base class itself) **on the client** ... and Breeze would propagate it to the derived classes.

        Breeze already propagates to the derived classes any validation rule set on the EF server-side base model class (e.g., a [Required] of [MaxLength] on the base BillingDetail class).

      • Martin KlemsaMartin Klemsa commented  · 

        @Sverre How about creating and assigning validators to properties present in the base class, so that multiple entity types share them?

      • Sverre AndreassenSverre Andreassen commented  · 

        I think automagically flattening the inheritance should work. I cannot think of any reason to know about the inheritance structure on the JavaScript side.

      • Ward BellWard Bell commented  · 

        While we will do this, and soon, I'm not sure we're all talking about the same thing. "Inheritance" in this case means database inheritance. Of course the model on the server can inherit from a base class. "Database inheritance" means that data for an entity are either split across several tables or (as in TPH) occupy a slice of one table and are identified by a discrimination column. "Database inheritance" support implies "polymorphic" queries that can return entities of multiple types. Frankly, I think database inheritance is usually a design error, a dubious attempt to project object-orientation onto a relational database. I avoid it like the plague. But, hey, if that's what you folks mean ... and want ... will give you the rope to hang yourselves.

      • ThanosThanos commented  · 

        With inheritance implemented, Breeze will be our first choice for our projects. Without it, I am not sure that it will help us at all!

      • Sverre AndreassenSverre Andreassen commented  · 

        Discovering that inheritance is not supported was a major disappointment. It is an absolute show stopper in my project. Sorry, no Breeze for me.

      • RonnieRonnie commented  · 

        Yes, Breeze is a great tool, but the lack of support for inheritance are currently keeping it out of our toolbox.

      • PawelPawel commented  · 

        Yes, we've just hit the same wall here. I wish you are working on it and it's coming. :)

      • PeterPeter commented  · 

        Once a DB model gets a little complex, inheritances immediately appear. I think supporting inheritance in Breeze is a top priority!

      Feedback and Knowledge Base