Exemplo n.º 1
0
 private void CreateCachedUserAndAdd(IUser user, uint userId, SqlDatabase <CachedUser> database)
 {
     using (var memoryStream = ConvertUserToMemoryStream(user))
     {
         var cachedUser = new CachedUser
         {
             Id            = userId,
             ProtoBufBytes = memoryStream.ToArray(),
         };
         var dbUser = database.Store.Where(x => x.Id == userId).FirstOrDefault();
         if (dbUser != null)
         {
             database.Store.Delete(x => x.Id == userId);
             database.Add(cachedUser);
         }
         else
         {
             database.Add(cachedUser);
         }
     }
 }
Exemplo n.º 2
0
 private void CreateCachedUserAndAdd(IUser user, uint userId, SqlDatabase<CachedUser> database)
 {
     using (var memoryStream = ConvertUserToMemoryStream(user))
     {
         var cachedUser = new CachedUser
         {
             Id = userId,
             ProtoBufBytes = memoryStream.ToArray(),
         };
         var dbUser = database.Store.Where(x => x.Id == userId).FirstOrDefault();
         if (dbUser != null)
         {
             database.Store.Delete(x => x.Id == userId);
             database.Add(cachedUser);
         }
         else
         {
             database.Add(cachedUser);
         }
     }
 }