One, type conversion
Two, variable parameters
Three, string
Iv. Delegation
Five, the constructor function
Vi. Expressions of Lamba
Vii. Linq
Viii. Entity Framework
1. Entry of the program: entities file suffix Context.cs
2. The database information is generated in a class corresponding to the database table in the file database name. The name of the table in TT (the name of the general EF is the same as the name of the database or the name of the project plus db)
3.EF database for deletion and modification
Increase:
Testentities entities = new testentities ();
User user = new user ();
User. Id = 1;
User. UserName = "Shine";
Entities. Users.add (user);
Entities. SaveChanges ();
Inquire:
var users = entities. Users.tolist ();
Delete
Entities. SaveChanges ();
var users = entities. Users.tolist ();
foreach (Var u in users)
{
Entities. Users.remove (U);
}
Entities. SaveChanges ();
Modify
var user2 = entities. Users.firstordefault (U = u.id = = 1);
if (user2! = null)
{
User2. UserName = "Shine";
Entities. SaveChanges ();
}
Shortcuts commonly used in VS
1. ctrl+f Find Current file
2, ctrl+shift+f find the entire solution
3. F9 Breakpoint
4, F10 Single Step
5, F11 Single Step Into
6, ctrl+-back to the previous step to see the file
7, SHIFT+F9 fast Monitoring
8, Shift+ctrl+b debugging
Tips
1. Code specification: General return can only be placed at the beginning or end of the program, or there is return in the middle of not know where to exit from
2. Generally go to the database when the data is taken out directly tolist
Open line number in 3.VS tool options
4.VS debugging when there is an error general steps: View Detail->innerexception expand to the innermost of the innerexception view can be, the specific figure is as follows
、
5. When the conversion is generally selected Int.tryparse this can avoid error
string s = String. Empty
int v1;
if (int. TryParse (S,out v1))
{
}
6. When loop traversal, foreach is used to not modify the value of the case, if you need to modify the values of traversed objects choose for traversal
Quick review of C # Basics (tips for programming) to be perfected