jeudi 23 novembre 2017

Data Access Layer when targeting 2 databases

I am working in an app (VB.NET) for my company that reads data from our ERP DB and writes into another DB, which is specific for the project. Main business of the app is to make automatic measurements (different measurements) of our devices and write the builded devices and their results to a DB.

Should I have 2 different projects (DAL) for each database? The DAL library that works with our ERP, will be used in other apps, while the library speaking to the project specific will only be used (for the moment) in this project.

I am also trying to learn and implement some architecture patterns and clean code principles...

So is the best idea to have 2 projects like

  • Company.ERPDataAccess (own Git Repo)
  • Company.Project.DataAccess (project Git Repo)

since I want ERPDataAccess to be reused but not Project.DataAccess (for the moment?)

Another question would be what about the specific domains (classes created by EF Designer)? Should I store them into the DB projects?

What if the DAL-Entities dont match my desired entities? (I am using DB First designer)?

For example, in the ERP-DB I have all our "stuff", for ex. a table called Articles with ALL our articles (also build pieces etc etc)

So I want to read data from ERP-DB (now using EF 6)....and build from it new entities, which I will use later in the app. So for example a domain entity in my app is pressureDevice, which contains a lot of articles from ERP-DB.Articles(for example an measureCell) and I need to build it(get device specs like range or mounted cell) from the data in my ERP-DB. What is here the best approach?

I think about having 2 Data Projects...Project.Data will use the entities provided by EF(for example a class Device). ERP-DataAcess will use its entities provided by EF (f.e. class Article).

Now in my domain model I would have specific device classes (i.e. PressureDevice, TemperatureDevice, etc. that inherit from Device, so I can write directly to the DB.

For example: I have ERP-DB.Articles with an entity article(items in this table are related to other items in the same table). In my project I have a domain entity PressureDevice and then I would have a "adapter" DeviceFactory, that knows how to use the ERP-DB-DAL to query the database and build a PressureDevice.

If this is the best approach, where do the adapter classes belong to? To the DAL projects, to another layer between BLL and DAL or just in my BLL in an "Adapters" namespace?

I am trying to implement and understand the patterns and principles in this my first bigger "solo" project I am working at, but I'm struggling a bit when trying to implement although I think I got the main ideas.

I hope I could make the problem understandable since English is not one of my powers:)

Aucun commentaire:

Enregistrer un commentaire