How can I get sub class entity set?

5 posts, 1 answers
  1. Tajes
    Tajes avatar
    81 posts
    Member since:
    Sep 2009

    Posted 16 Mar 2011 Link to this post

    Hello,
    I'm using visual designer and the contextdb object to access to data. I have a entity class and a entity subclass derived.
    How can I get from the contextdb the entity set of the sub class? I can only get the parent class entity set (contextdb.parentClasses)
  2. Zoran
    Admin
    Zoran avatar
    534 posts

    Posted 18 Mar 2011 Link to this post

    Hi Tajes,

     We tested the scenario you described - having inheritance in our designer and the context is always generated with endpoints for all of the classes - base classes or subclasses. If your context is not being generated with an endpoint for your derived class - it means this is a bug on our side. However since we did not reproduce it, I would like to ask you if you could send us your .rlinq file so we can test the behavior locally and if a bug is confirmed - deliver a fix as soon as possible.

    Best wishes,
    Zoran
    the Telerik team
  3. DevCraft banner
  4. Tajes
    Tajes avatar
    81 posts
    Member since:
    Sep 2009

    Posted 18 Mar 2011 Link to this post

    Hello Zoran,
    Thank you for your quick reply. I have installed the Q1 2011 release and the issue has been corrected. Only one question more:
    If I have another class related with the parent class, how can I select only the subclass' items through the navigation property of the first class?

    class ParentClass{}
     
    class SubClass{}
     
    class OtherClass
    {
        IList<ParentClass> navigationProperty;
    }
    //.......................................................
    OtherClass otherClass;
     
    var subClasses = from x in otherClass.navigationProperty select x;//<--How can I get only SubClass items?

    thanks in advance.
  5. Answer
    Zoran
    Admin
    Zoran avatar
    534 posts

    Posted 22 Mar 2011 Link to this post

    Hello Tajes,

     Here is the query you could write to get the  SubClass items of a collection of ParentClass items:

    var subEntitiesList = Context.OtherClasses.SelectMany(p => p.navigationProperty.OfType<SubClass>());

    Context would be the Generated OpenAccessConetxtClass from the Visual Designer that has IQueryable endpoints for all of the entities as its properties.


    Greetings,
    Zoran
    the Telerik team
  6. Tajes
    Tajes avatar
    81 posts
    Member since:
    Sep 2009

    Posted 22 Mar 2011 Link to this post

    Thank you very much Zoran
Back to Top
DevCraft banner