OnlineOAEntities dbContext=new OnlineOAEntities ();
# add operation region
//declare a User entity
The UserInfo user=new the UserInfo ();
The user. The UserName="user20180723";
The user. The PassWord="123456";
//tell EF for the above entity do an insert
DbContext. The UserInfo. Add (user);
4, tell context entities to save changes to database
DbContext. SaveChanges ();
# endregion
# region change
//2, declare a User entity
The UserInfo user=new the UserInfo ();
The user. The UserName="user20180723";
The user. The PassWord="123456";
User. Id=2;
//3, tell EF to modify the above entity do a operation
//dbContext. Entry
DbContext. The UserInfo. Attach (user);//the user is attached to the context to manage
DbContext. Entry
//4, tell context entities to save changes to database
DbContext. SaveChanges ();
# endregion
# region delete
//2, declare a User entity
The UserInfo user=new the UserInfo ();
//user. The UserName="user20180723";
//user PassWord="123456";
User Id=19//3, told EF to modify the above entity do a operation
DbContext. Entry
//4, tell context entities to save changes to database
DbContext. SaveChanges ();
# endregion
# region query
//the user list below all data printed again
Foreach (var user in dbContext. The UserInfo)
{
Console. WriteLine (user) + "" + user Id) the UserName +" "+ user. The PassWord).
}
# endregion
# region linq query
//the return value is the IQueryable linq expression
IQueryable
Where u.I d> 10
The select u;
The foreach (var UI in temp)
{
Console. WriteLine (UI. Id + "" + UI. The UserName +" "+ UI. The PassWord).
}
#endregion
CodePudding user response:

CodePudding user response:
What do you want to express?CodePudding user response:

CodePudding user response:
You want to express?CodePudding user response:
Want to scatter points
CodePudding user response:
Pick up points
CodePudding user response:
What you get what?