Public class a
{
Public int id {get; The set; }
Public B B {get; The set; }
}
Public class B
{
Public int id {get; The set; }
Public string name {get; The set; }
}
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Because of ef tracking database search out data, changes in the service or other higher a content, after the
Inside the update (a) savechanges (), it is easy to save some don't want to want to save the information,
And uncertain state of b, it is easy to programming to insert a, b
If in service careful, avoid these situations, the stratification is not complete, top write, the in the mind time considering the contents of the DAO layer,
Authentic EF DAO is how to write,
I had been writing JAVA, using ibatis, because not so smart, all good layering instead,
Now not line, all mixed together,
thank you
CodePudding user response:
Speaking ashamed, study the problem already more than half a year, has always no good solutionCodePudding user response:
Ef only in a small project used, is not so entangled with layeredCodePudding user response:
Advanced is advanced, but doesn't seem appropriate stratification,CodePudding user response:
Entry. The Property (" id "). IsModified=true;Entry. The Property (" b "). IsModified=false;
Savechanges
Update when can manually identify whether a field changes before the savechanges
CodePudding user response:
How to say,Use ef, in fact you have the dao, all is ok,
Because ef is belongs to the category of the dao,
Only you may have other data acquisition, need special treatment, then you will create the dao,
Relatively simple example is, although you use ef,
But may also use this method in ef to direct use of SQL statements,
That this part, I may be in the dao,
CodePudding user response:
Java (Controller + Service + Dao) :Dao (Data Access Object) : Data storage Object - & gt; Service: Service - & gt; Controller: a Controller
Dao: be responsible for your service account really delete the
Service: be responsible for handling delete the role of logic, or delete the role to delete user
Controller: receive parameters, tell I want to delete this role, the service layer and returns the results
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
CSharp (UI + the BLL + DAL + Model (Entity) :
The UI presentation & lt; - the BLL the business logic layer & lt; - DAL (data access layer) & lt; - Model (Entity) Entity class library
System structure of three-layer architecture: the presentation layer and business logic layer using the object model between entity class object to pass data, business logic layer and data access layer using the object model between entity class object to pass data, through the data access layer..net provides ADO.NET component to manipulate the database, or use essentially a database server stored procedure to complete data operation,
The layered architecture has the following four advantages:
(1) to avoid the direct access to the data access layer, presentation layer only contact with the business logic layer, improve the data security,
(2) for system development, each layer can be developed by different people, as long as follow the interface standard, using the same object model entity class is ok, so you can greatly improve the system development speed,
(3) the migration of system, convenient if you want to turn a C/S system to B/S system, as long as the modified three layer architecture of the presentation layer, business logic layer and data access layer almost without modifying it can easily transplant system on the network,
(4) the project structure more clearly, division of labor is more clear, is conducive to the late maintenance and upgrade,
On the basis of three-tier architecture, also exists in a hybrid architecture:
The UI - & gt; CallerFactory interface application layer - & gt; The Facade interface layer - & gt; WinForm call level
-> WCF service layer - & gt; WCF service invocation layer
-> The BLL business layer - & gt; IDAL/DAL data access layer - & gt; Oracle/used/MySql database layer
CodePudding user response:
666, thanks for sharing the