Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. LINQ
  4. Polymorphism Questions with EntityFramework

Polymorphism Questions with EntityFramework

Scheduled Pinned Locked Moved LINQ
questioncsharpdatabaselinqoop
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Juvil John
    wrote on last edited by
    #1

    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)??

    P 1 Reply Last reply
    0
    • J Juvil John

      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)??

      P Offline
      P Offline
      Patrik karlin
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups