Polymorphism Questions with EntityFramework
-
I have a this class structure Class1 -> EF (EntityObject from the Entity Data Model) CustomClass1 : Class1 -> Custom class Inherited class from EntityObject Class1 now I wanted to CustomClass1 custom1 = new CustomClass1; Class1 baseclass = (Class1)CustomClass1; baseclass = ( LINQ to EDM Query).First(); now how do i load back the baseclass object to custom1 (CustomClass1)??
-
I have a this class structure Class1 -> EF (EntityObject from the Entity Data Model) CustomClass1 : Class1 -> Custom class Inherited class from EntityObject Class1 now I wanted to CustomClass1 custom1 = new CustomClass1; Class1 baseclass = (Class1)CustomClass1; baseclass = ( LINQ to EDM Query).First(); now how do i load back the baseclass object to custom1 (CustomClass1)??
Hej Juvil John As i se it custum1 is first set as a CustomClass1 object and is given a new reference to it. The you move the reference to baseclass witch is a class1 object. Butt here comes the strange thing you show this baseclass = ( LINQ to EDM Query).First(); Witch should render the first code meaningless since the reference to the CustomClass1 is now gone and replaced whit the first object of the query ( witch i don't now the type of butt i am assuming its a class1 since your not casting it). So then you cant cast it back because the object its now referenced to is of the wrong type. If i gott it rigth then tell me what your trying to accomplish by this( Adding methods tho the type ?? ) Becuse then there is other ways of doing it.