digipolisantwerp / dataaccess_aspnetcore_deprecated

Generic repository/unit of work framework for ASP.NET Core with Entity Framework.
Other
140 stars 45 forks source link

Inherited Entity #36

Closed m2017atTR closed 7 years ago

m2017atTR commented 7 years ago
myFurnitureBase :BaseEntity {
  string Name;
  string Description;
}

myHomeFurnitureEntity : myFurnitureBase {
  string myTalbeSpecificProperty;
}

myOfficeFurnitureEntity : myFurnitureBase {
  string myChairSpecificProperty;
}

... there is more type

  dbset<myHomeFurnitureEntity>
  dbset<myOfficeFurnitureEntity >
... 

and Is that possible to query myHomeFurnitureEntity and myOfficeFurnitureEntity as myFurnitureBase or how to create generic repository/pager dynamically

I want to show a page that wil list with category,

          if query string/model 
                contains home then 
                    controller must return from myHomeFurnitureEntity as myFurnitureBase 
               contains work then 
                    controller must return from myOfficeFurnitureEntity as myFurnitureBase 

thanks.

StevenVandenBroeck commented 7 years ago

I'm not sure that is possible with our current generic repositories. You could try it, following the conventions that EF core prescribes (more info here: https://docs.microsoft.com/en-us/ef/core/modeling/inheritance and here : https://docs.microsoft.com/en-us/ef/core/modeling/relational/inheritance). If it doesn't work, you'll have to write your own repository for it, inheriting from RepositoryBase.