public void UpdateBatch(ISessionWrapper session, IReadOnlyCollection <SVR_AnimeSeries> seriesBatch) { if (session == null) { throw new ArgumentNullException(nameof(session)); } if (seriesBatch == null) { throw new ArgumentNullException(nameof(seriesBatch)); } if (seriesBatch.Count == 0) { return; } foreach (SVR_AnimeSeries series in seriesBatch) { lock (globalDBLock) { session.Update(series); lock (Cache) { Cache.Update(series); } } lock (Changes) { Changes.AddOrUpdate(series.AnimeSeriesID); } } }
/// <summary> /// Inserts a batch of <see cref="SVR_AnimeGroup_User"/> into the database. /// </summary> /// <remarks> /// <para>It is up to the caller of this method to manage transactions, etc.</para> /// <para>Group Filters, etc. will not be updated by this method.</para> /// </remarks> /// <param name="session">The NHibernate session.</param> /// <param name="groupUsers">The batch of <see cref="SVR_AnimeGroup_User"/> to insert into the database.</param> /// <exception cref="ArgumentNullException"><paramref name="session"/> or <paramref name="groupUsers"/> is <c>null</c>.</exception> public void UpdateBatch(ISessionWrapper session, IEnumerable <SVR_AnimeGroup_User> groupUsers) { if (session == null) { throw new ArgumentNullException(nameof(session)); } if (groupUsers == null) { throw new ArgumentNullException(nameof(groupUsers)); } foreach (SVR_AnimeGroup_User groupUser in groupUsers) { session.Update(groupUser); ChangeTracker <int> changeTracker; if (!Changes.TryGetValue(groupUser.JMMUserID, out changeTracker)) { changeTracker = new ChangeTracker <int>(); Changes[groupUser.JMMUserID] = changeTracker; } changeTracker.AddOrUpdate(groupUser.AnimeGroupID); } }
/// <summary> /// Updates a batch of <see cref="SVR_GroupFilter"/>s. /// </summary> /// <remarks> /// This method ONLY updates existing <see cref="SVR_GroupFilter"/>s. It will not insert any that don't already exist. /// </remarks> /// <param name="session">The NHibernate session.</param> /// <param name="groupFilters">The batch of <see cref="SVR_GroupFilter"/>s to update.</param> /// <exception cref="ArgumentNullException"><paramref name="session"/> or <paramref name="groupFilters"/> is <c>null</c>.</exception> public void BatchUpdate(ISessionWrapper session, IEnumerable <SVR_GroupFilter> groupFilters) { if (session == null) { throw new ArgumentNullException(nameof(session)); } if (groupFilters == null) { throw new ArgumentNullException(nameof(groupFilters)); } lock (globalDBLock) { lock (Cache) { foreach (SVR_GroupFilter groupFilter in groupFilters) { lock (groupFilter) { session.Update(groupFilter); Cache.Update(groupFilter); } } } } }
public void UpdateBatch(ISessionWrapper session, IReadOnlyCollection <SVR_AnimeGroup> groups) { if (session == null) { throw new ArgumentNullException(nameof(session)); } if (groups == null) { throw new ArgumentNullException(nameof(groups)); } foreach (SVR_AnimeGroup group in groups) { lock (globalDBLock) { lock (group) { session.Update(group); lock (Cache) { Cache.Update(group); } } } } Changes.AddOrUpdateRange(groups.Select(g => g.AnimeGroupID)); }
//This function do not run the BeginDeleteCallback and the EndDeleteCallback public virtual void SaveWithOpenTransaction(ISessionWrapper session, T obj) { if (Equals(SelectKey(obj), default(S))) { session.Insert(obj); } else { session.Update(obj); } SaveWithOpenTransactionCallback?.Invoke(session, obj); Cache.Update(obj); }
/// <summary> /// Updates a batch of <see cref="GroupFilter"/>s. /// </summary> /// <remarks> /// This method ONLY updates existing <see cref="GroupFilter"/>s. It will not insert any that don't already exist. /// </remarks> /// <param name="session">The NHibernate session.</param> /// <param name="groupFilters">The batch of <see cref="GroupFilter"/>s to update.</param> /// <exception cref="ArgumentNullException"><paramref name="session"/> or <paramref name="groupFilters"/> is <c>null</c>.</exception> public void BatchUpdate(ISessionWrapper session, IEnumerable <GroupFilter> groupFilters) { if (session == null) { throw new ArgumentNullException(nameof(session)); } if (groupFilters == null) { throw new ArgumentNullException(nameof(groupFilters)); } foreach (GroupFilter groupFilter in groupFilters) { session.Update(groupFilter); } }
/// <summary> /// Updates a batch of <see cref="SVR_GroupFilter"/>s. /// </summary> /// <remarks> /// This method ONLY updates existing <see cref="SVR_GroupFilter"/>s. It will not insert any that don't already exist. /// </remarks> /// <param name="session">The NHibernate session.</param> /// <param name="groupFilters">The batch of <see cref="SVR_GroupFilter"/>s to update.</param> /// <exception cref="ArgumentNullException"><paramref name="session"/> or <paramref name="groupFilters"/> is <c>null</c>.</exception> public void BatchUpdate(ISessionWrapper session, IEnumerable<SVR_GroupFilter> groupFilters) { if (session == null) throw new ArgumentNullException(nameof(session)); if (groupFilters == null) throw new ArgumentNullException(nameof(groupFilters)); lock (globalDBLock) { lock (Cache) { foreach (SVR_GroupFilter groupFilter in groupFilters) <<<<<<< HEAD:Shoko.Server/RepositoriesOld/Cached/GroupFilterRepository.cs lock (groupFilter) { session.Update(groupFilter); Cache.Update(groupFilter); }
public void UpdateBatch(ISessionWrapper session, IReadOnlyCollection <AnimeSeries> seriesBatch) { if (session == null) { throw new ArgumentNullException(nameof(session)); } if (seriesBatch == null) { throw new ArgumentNullException(nameof(seriesBatch)); } if (seriesBatch.Count == 0) { return; } foreach (AnimeSeries series in seriesBatch) { session.Update(series); Changes.AddOrUpdate(series.AnimeSeriesID); } }