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.
The main character of this series will always be linqtosql. dbml is generally called data object relationship ing or Orm. In short, it is a relationship between a database and an object. This relationship is called mapping. In linqtosql, we directly place a database object in the dbml file, and this relational ing is formed. That is to say, you can operate the database to directly operate the entity type in dbml in the future.
When we use an ORM tool, we always have a habit of abstracting what needs to be abstracted, because it is easier to manage and the structure is more object-oriented, should we abstract the linqtosql object class? In fact, Microsoft has already told us the answer when designing the linqtosql entity class, that is, "Yes, yes". We can see from the object type using the partial modifier that, microsoft hopes that we can reabstract it in a line and add the things required by the project to the entity class. In the project,CodeIt may be like this:
1 /// <Summary> 2 /// User entity 4 /// </Summary> 5 Public Partial Class Userbases: entitybase 6 { 7 /// <Summary> 8 /// Unified primary key 9 /// </Summary> 10 Protected Override Object [] Primarykey 11 { 12 Get { Return New Object [] { This . Userid };} 13 } 14 15 /// <Summary> 16 /// Field changes 17 /// </Summary> 18 Public Override Void Onpropertychange () 19 { 20 If ( This . Isvalid) // Whether the entity has been verified 21 22 { 23 Base . Onloaded (); 24 This . Propertychanged + = New Propertychangedeventhandler ( Base . Propertychangedevent ); 25 } 26 } 27 }
In the userbases object, because it inherits the unified entity abstract class entitybase, the method parameters and return values can be written as follows when the data layer performs the unified entity Gurd operation:
1 Protected VirtualIqueryable <entitybase> getentities <tentity> (expression <func <tentity,Bool> Queryfunc)WhereTentity: entitybase2 {3}
Entity abstraction is not only linqtosql, but also applicable to the actual architecture.