What can we learn from Microsoft's dbml files (it tells us what is the top priority of Microsoft )~ In linqtosql, sendpropertychanging and sendpropertychanged are triggered for us.

Source: Internet
Author: User

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.
 
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.