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); } } }
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); } } }