public void AddFriend(string userId, List<string> friendIds)
 { 
     //以一百个为单位保存
     int count = 0;
     foreach (var friendId in friendIds)
     {
         try
         {
             FriendRelation addModel = new FriendRelation()
             {
                 Id = Guid.NewGuid(),
                 CreateTime = DateTime.Now,
                 UserId = StringHelper.LimitLength(userId),
                 FriendId = StringHelper.LimitLength(friendId),
                 IsFocus = false
             };
             db.AddToFriendRelations(addModel);
             count++;
             if (count > 100)
             {
                 db.SaveChanges();
                 count = 0;
             }
         }
         catch
         {
             throw new Exception("保存出错");
         }
         finally
         {
             db.SaveChanges();
         }
     }
 }
        public void AddFriend(string userId, string friendId)
        {
            try
            {
                FriendRelation addModel = new FriendRelation()
                {
                    Id = Guid.NewGuid(),
                    CreateTime = DateTime.Now,
                    UserId = StringHelper.LimitLength(userId),
                    FriendId = StringHelper.LimitLength(friendId),
                    IsFocus = false
                };
                db.AddToFriendRelations(addModel);
                db.SaveChanges();
            }
            catch
            {
                throw new Exception("数据保存出错");
            }

        }
 /// <summary>
 /// 用于向 FriendRelations EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToFriendRelations(FriendRelation friendRelation)
 {
     base.AddObject("FriendRelations", friendRelation);
 }
 /// <summary>
 /// 创建新的 FriendRelation 对象。
 /// </summary>
 /// <param name="id">Id 属性的初始值。</param>
 /// <param name="createTime">CreateTime 属性的初始值。</param>
 /// <param name="userId">UserId 属性的初始值。</param>
 /// <param name="friendId">FriendId 属性的初始值。</param>
 /// <param name="isFocus">IsFocus 属性的初始值。</param>
 public static FriendRelation CreateFriendRelation(global::System.Guid id, global::System.DateTime createTime, global::System.String userId, global::System.String friendId, global::System.Boolean isFocus)
 {
     FriendRelation friendRelation = new FriendRelation();
     friendRelation.Id = id;
     friendRelation.CreateTime = createTime;
     friendRelation.UserId = userId;
     friendRelation.FriendId = friendId;
     friendRelation.IsFocus = isFocus;
     return friendRelation;
 }