A dbcontext constructor, method Overloading
In the binary dbcontext instance, how is a table object added?
Does the three branch categories undermine a single responsibility?
The four-segment method defines the type operation specifications from the other hand.
5. assign values to attributes in the LINQ object class. Before and after the changes, sendpropertychanging and sendpropertychanged
Six linqtosql triggers sendpropertychanging and sendpropertychanged for us. What is its true intention?
7. The dbcontext object should be used as the base class of other object operation types and provide unified submission actions for it.
NextArticleWhen it comes to modifying attributes, LINQ will help us trigger two events:
Public eventPropertychangingeventhandlerPropertychanging;Public eventPropertychangedeventhandlerPropertychanged;
So how can it be used in actual projects? I will use a project I wrote recently to explain its usage:
Implementation function: Unified updates, without using the update of the SQL to SQL, using the update of the T-SQL
Implementation idea: sort the fields and values to be updated, and then find the real table name and Table Primary Key of the object to be updated.
Core Knowledge: propertychanging and propertychanged events help us collect the fields to be updated
Professional knowledge: retriable indicates the abstraction of real data tables. You can obtain real data table Objects Based on Object objects.
CoreCode:
Unified abstract base class:
Human intervention is required for specific object:
Running process: when an object is loaded, it automatically subscribes to a propertychanged object and points to the propertychangedevent of the base class. Its main function is to record the fields to be modified and
Then, the UI Layer assigns values to the new object and submits the values to BLL (service) or Dal (data) (small projects do not need BLL ), you can call the underlying unified modification method.
This project is different from other projects in that the project and instance project are separated.
Later, directly reference entity. the Commons project is fine. Different projects have different entity. Here, entity is called an instance project. If the project you want to work on has only one database, it may be a front-end sub-module project. The entity layer can also be public, and the data layer is public. You only need to redesign the service layer and UI Layer.