Esempio n. 1
0
 //添加用户
 public void AddUser(ServerUser user)
 {
     DatabaseUser newUser = new DatabaseUser()
     {
         UserName = user.UserName,
         NickName = user.NickName,
         Gender = user.Gender.ToString(),
         Email = user.Email,
         Age = user.Age,
         Password = user.Password
     };
     foreach (string username in user.FriendNames)
     {
         UserFriend newFriend = new UserFriend() { UserName = username };
         newUser.UserFriend.Add(newFriend);
     }
     dataContext.DatabaseUser.InsertOnSubmit(newUser);
     dataContext.SubmitChanges();
 }
Esempio n. 2
0
		private void detach_UserFriend(UserFriend entity)
		{
			this.SendPropertyChanging();
			entity.DatabaseUser = null;
		}
Esempio n. 3
0
 //添加用户好友
 public void MakeFriends(string sender, string receiver)
 {
     //将receiver添加到sender朋友列表里
     var currentSender = (from u in dataContext.DatabaseUser
                          where u.UserName == sender
                          select u).Single();
     //避免重复添加
     var checkUser = from u in currentSender.UserFriend
                     where u.UserName == receiver
                     select u;
     if (checkUser.Count() == 0)
     {
         UserFriend newFriend = new UserFriend()
         {
             UserName = receiver
         };
         currentSender.UserFriend.Add(newFriend);
     }
     //将sender添加到receiver朋友列表里
     var currentReceiver = (from u in dataContext.DatabaseUser
                            where u.UserName == receiver
                            select u).Single();
     //避免重复添加
     checkUser = from u in currentReceiver.UserFriend
                     where u.UserName == receiver
                     select u;
     if (checkUser.Count() == 0)
     {
         UserFriend newFriend = new UserFriend()
         {
             UserName = sender
         };
         currentReceiver.UserFriend.Add(newFriend);
     }
     dataContext.SubmitChanges();
 }
Esempio n. 4
0
 partial void UpdateUserFriend(UserFriend instance);
Esempio n. 5
0
 partial void DeleteUserFriend(UserFriend instance);
Esempio n. 6
0
 partial void InsertUserFriend(UserFriend instance);
Esempio n. 7
0
 private void detach_UserFriend(UserFriend entity)
 {
     this.SendPropertyChanging();
     entity.DatabaseUser = null;
 }
Esempio n. 8
0
 partial void DeleteUserFriend(UserFriend instance);
Esempio n. 9
0
 partial void UpdateUserFriend(UserFriend instance);
Esempio n. 10
0
 partial void InsertUserFriend(UserFriend instance);