Using Repository Pattern with Entity DataModel
Posted: Mon 29 Feb 2016 16:58
I am experimenting with the dotConnect Entity Data Model to use with our Oracle db and I want to know if I can:
1. Change the class/properties names so they are not the same as the tables in our Oracle database (which are confusing). The wizard always creates the Data Model classes/properties with the same names as the underlying tables. There doesn't seem to be any way to rename the files under the .edml file.
2. I want to structure the app so my domain objects are separate from the persistence layer, but the wizard puts the dbContext-derived class and domain classes under the .edml file and I am unable to separate them. Basically, this is how my solution should look:
Visual Studio Solution:
Core (parent folder for core abstractions)
-Domain(this folder should contain only the model classes that represent the tables in my db)
Customer.cs
Product.cs
-Repositories (this folder has interfaces for each domain object repo and the generic repo for all obj)
IRepository.cs // for generic domain object functionality. eg, Add() Remove() Get() GetAll().
ICustomerRepository.cs //for object-specific queries. eg, GetTopCustomers()
IProductRepository.cs //for object-specific queries. eg, GetBestSellingProducts()
Persistence (parent folder for database-specific implementations)
MyAppDbContext.cs (dbContext-derived class with DbSets<> of domain objects)
-Repositories (this folder should contain the implementation of my repository interfaces) eg:
Repository.cs //implements the generic repository interface with EF version
CustomerRepository.cs //inherits from the generic repository AND implements the ICustomerRepo
ProductRepository.cs //inherits from the generic repository AND implements the IProductRepo
This solution will reduce query duplication in outer layers. Any ideas on how to achieve this with devart tools?
1. Change the class/properties names so they are not the same as the tables in our Oracle database (which are confusing). The wizard always creates the Data Model classes/properties with the same names as the underlying tables. There doesn't seem to be any way to rename the files under the .edml file.
2. I want to structure the app so my domain objects are separate from the persistence layer, but the wizard puts the dbContext-derived class and domain classes under the .edml file and I am unable to separate them. Basically, this is how my solution should look:
Visual Studio Solution:
Core (parent folder for core abstractions)
-Domain(this folder should contain only the model classes that represent the tables in my db)
Customer.cs
Product.cs
-Repositories (this folder has interfaces for each domain object repo and the generic repo for all obj)
IRepository.cs // for generic domain object functionality. eg, Add() Remove() Get() GetAll().
ICustomerRepository.cs //for object-specific queries. eg, GetTopCustomers()
IProductRepository.cs //for object-specific queries. eg, GetBestSellingProducts()
Persistence (parent folder for database-specific implementations)
MyAppDbContext.cs (dbContext-derived class with DbSets<> of domain objects)
-Repositories (this folder should contain the implementation of my repository interfaces) eg:
Repository.cs //implements the generic repository interface with EF version
CustomerRepository.cs //inherits from the generic repository AND implements the ICustomerRepo
ProductRepository.cs //inherits from the generic repository AND implements the IProductRepo
This solution will reduce query duplication in outer layers. Any ideas on how to achieve this with devart tools?