P
P
Pavel_Develop2015-08-12 12:52:46
OOP
Pavel_Develop, 2015-08-12 12:52:46

Entity Framework and OOP. How to correctly implement the principle of consistency?

During the showdown with DDD, a question arose that breaks my brain.
On the example of such a subject area:
There is a small store, it is necessary to automate the process of selling and receiving products in the warehouse.
We have three versions of the document with which the store works: Receipt, Return from the buyer, Invoice.
Cases (we take the usual trivial cases):
1. Sale: a person comes, a check breaks through, the goods are written off from the nomenclature.
2. Return from the buyer: a person comes, a return is issued, the goods are returned to the warehouse.
3. Invoice: goods arrive, an invoice is drawn up, the goods are added to the warehouse.
Now let's try to break it down into entities:
1. If we take from the side of Domain-Driven Design:
Product - product
Order - check
OrderLine - position in the check, which cannot exist without a check and product and writes off the quantity of goods in the warehouse
Return - Return from the buyer, adds the quantity of goods
ReturnLine - position in the return
Consignment - invoice
ConsigmentLine - position in the invoice, adds the quantity of goods
2 Data-Driven Design:
Product - product
Document - document with type(Receipt, Return, Invoice)
DocumentLine - document item
How to correctly implement the connection between Business and Database levels? Mapping?
In the case of using mapping, how to solve the problem of saving, adding positions if Entity Framework is used?
Is it possible to use the Code First approach to implement classes from Domain-Driven to work with the database, and so that there is only one table?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stanislav Makarov, 2015-08-12
@Pavel_Develop

> How correctly to implement communication between Business and Database levels? Mapping?
Why do you need EF then?
> In the case of using mapping, how to solve the problem of saving, adding positions if Entity Framework is used?
Any normal ORM has the ability to map collections of elements in one form or another. Adding a position to the collection, with proper mapping, should result in rows being added to the corresponding table with the desired foreign key values.
> at what that the table was one?
About one table at all did not understand. What is one table?

P
Pavel_Develop, 2015-08-12
@Pavel_Develop

What we managed to dig up:
Work directly with the entities that the ORM generates using the Repository. And all business logic is located in Service. Mapping is done using AutoMapper using the ViewModel on the Presentation side. Sometimes Service and Repository are split into small Query and Command classes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question