/// <summary>
 /// 创建新的 AchievementTrendTable 对象。
 /// </summary>
 /// <param name="id">Id 属性的初始值。</param>
 /// <param name="userId">UserId 属性的初始值。</param>
 /// <param name="achievement">Achievement 属性的初始值。</param>
 /// <param name="time">Time 属性的初始值。</param>
 public static AchievementTrendTable CreateAchievementTrendTable(global::System.Int32 id, global::System.Int32 userId, global::System.String achievement, global::System.String time)
 {
     AchievementTrendTable achievementTrendTable = new AchievementTrendTable();
     achievementTrendTable.Id = id;
     achievementTrendTable.UserId = userId;
     achievementTrendTable.Achievement = achievement;
     achievementTrendTable.Time = time;
     return achievementTrendTable;
 }
 private void dealWithAchievement(UserTable user)
 {
    // List<int> list_FriendId = db.FriendTables.Where(c => c.UserId == userId).Select(c => c.FriendId).ToList<int>();
    
    // list_FriendId.Add(userId);
     //foreach (int j in list_FriendId) Console.WriteLine(j);
     int[] Num=new int[10];
     //foreach (int friendId in list_FriendId)
    // {
      //   {
         // //   if (user.Id == friendId)
           //  {
                 if (user.NowRank<=8 && user.LastRank > 8)
                 {
                     AchievementTrendTable achievementTable = new AchievementTrendTable()
                     {
                         Achievement="rise to NO."+user.NowRank,
                         Time=DateTime.Now.ToShortDateString(),
                         UserId=user.Id
                     };
                 
                     db.AchievementTrendTables.AddObject(achievementTable);
                     
                 }
                 if (user.NowRank == 1 && user.LastRank != 1)
                 {
                     foreach (ItemTable item in db.ItemTables.Where(c=>c.UserId==user.Id))
                     {
                         Num[item.CategoryId]+=item.Amount;
                     }
                     int max=0;
                     int categotyId=0;
                     for(int j=1;j<=6;j++)
                     {
                         if(Num[j]>max)
                         {
                             max=Num[j];
                             categotyId=j;
                         }
                     }
                     string categoryName=db.CategoryTables.SingleOrDefault(c=>c.Id==categotyId).Name;
                     AchievementTrendTable achievementTable = new AchievementTrendTable()
                     {
                         Achievement = categoryName,
                         Time = DateTime.Now.ToShortDateString(),
                         UserId = user.Id
                     };
                     db.AchievementTrendTables.AddObject(achievementTable);
                 }
               
                 
     db.SaveChanges();
 }
 /// <summary>
 /// 用于向 AchievementTrendTables EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToAchievementTrendTables(AchievementTrendTable achievementTrendTable)
 {
     base.AddObject("AchievementTrendTables", achievementTrendTable);
 }