Vishwas Kadamannaya

Vishwas Kadamannaya

  • 1.6k
  • 122
  • 142.5k

Self Join EF Tables and Get Parent Child Relation

Oct 13 2023 9:54 AM

I have a ef class model - entity for "Resource" which has many properties around 130. This class "Resource" has a property called "ParentId", so basically a Resouce can have child or can have no child - which is linked to the same entity by key called "ParentId"

I have a db table , and its entity looks in ef as attached in image 

I want to write a Linq query to get all parent and childrens with the attached format as in image

Can you help me how can i achive this in by querying in ef.

 

 


Answers (1)