This is a migrated thread and some comments may be shown as answers.

How can I get sub class entity set?

4 Answers 66 Views
Getting Started
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Tajes
Top achievements
Rank 1
Tajes asked on 16 Mar 2011, 05:41 PM
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)

4 Answers, 1 is accepted

Sort by
0
Zoran
Telerik team
answered on 18 Mar 2011, 09:11 AM
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
0
Tajes
Top achievements
Rank 1
answered on 18 Mar 2011, 09:36 AM
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.
0
Accepted
Zoran
Telerik team
answered on 22 Mar 2011, 06:20 PM
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
0
Tajes
Top achievements
Rank 1
answered on 22 Mar 2011, 06:27 PM
Thank you very much Zoran
Tags
Getting Started
Asked by
Tajes
Top achievements
Rank 1
Answers by
Zoran
Telerik team
Tajes
Top achievements
Rank 1
Share this question
or