/src/NHibernate/Async/ISessionFactory.cs
https://github.com/RogerKratz/nhibernate-core · C# · 222 lines · 95 code · 19 blank · 108 comment · 13 complexity · 9a8da84c103ba58761230f8146247acf MD5 · raw file
- //------------------------------------------------------------------------------
- // <auto-generated>
- // This code was generated by AsyncGenerator.
- //
- // Changes to this file may cause incorrect behavior and will be lost if
- // the code is regenerated.
- // </auto-generated>
- //------------------------------------------------------------------------------
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Data.Common;
- using NHibernate.Connection;
- using NHibernate.Engine;
- using NHibernate.Impl;
- using NHibernate.Metadata;
- using NHibernate.Stat;
- using NHibernate.Util;
- namespace NHibernate
- {
- using System.Threading.Tasks;
- using System.Threading;
- public static partial class SessionFactoryExtension
- {
- /// <summary>
- /// Evict an entry from the second-level cache. This method occurs outside
- /// of any transaction; it performs an immediate "hard" remove, so does not respect
- /// any transaction isolation semantics of the usage strategy. Use with care.
- /// </summary>
- /// <param name="factory">The session factory.</param>
- /// <param name="entityName">The name of the entity to evict.</param>
- /// <param name="id"></param>
- /// <param name="tenantIdentifier">Tenant identifier</param>
- /// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param>
- public static async Task EvictEntityAsync(this ISessionFactory factory, string entityName, object id, string tenantIdentifier, CancellationToken cancellationToken = default(CancellationToken))
- {
- cancellationToken.ThrowIfCancellationRequested();
- if (tenantIdentifier == null)
- await (factory.EvictEntityAsync(entityName, id, cancellationToken)).ConfigureAwait(false);
- await (ReflectHelper.CastOrThrow<SessionFactoryImpl>(factory, "multi-tenancy").EvictEntityAsync(entityName, id, tenantIdentifier, cancellationToken)).ConfigureAwait(false);
- }
- /// <summary>
- /// Evict an entry from the process-level cache. This method occurs outside
- /// of any transaction; it performs an immediate "hard" remove, so does not respect
- /// any transaction isolation semantics of the usage strategy. Use with care.
- /// </summary>
- /// <param name="factory">The session factory.</param>
- /// <param name="roleName">Collection role name.</param>
- /// <param name="id">Collection id</param>
- /// <param name="tenantIdentifier">Tenant identifier</param>
- /// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param>
- public static async Task EvictCollectionAsync(this ISessionFactory factory, string roleName, object id, string tenantIdentifier, CancellationToken cancellationToken = default(CancellationToken))
- {
- cancellationToken.ThrowIfCancellationRequested();
- if (tenantIdentifier == null)
- await (factory.EvictCollectionAsync(roleName, id, cancellationToken)).ConfigureAwait(false);
- await (ReflectHelper.CastOrThrow<SessionFactoryImpl>(factory, "multi-tenancy").EvictCollectionAsync(roleName, id, tenantIdentifier, cancellationToken)).ConfigureAwait(false);
- }
- /// <summary>
- /// Evict all entries from the process-level cache. This method occurs outside
- /// of any transaction; it performs an immediate "hard" remove, so does not respect
- /// any transaction isolation semantics of the usage strategy. Use with care.
- /// </summary>
- /// <param name="factory">The session factory.</param>
- /// <param name="persistentClasses">The classes of the entities to evict.</param>
- /// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param>
- public static async Task EvictAsync(this ISessionFactory factory, IEnumerable<System.Type> persistentClasses, CancellationToken cancellationToken = default(CancellationToken))
- {
- cancellationToken.ThrowIfCancellationRequested();
- if (factory is SessionFactoryImpl sfi)
- {
- await (sfi.EvictAsync(persistentClasses, cancellationToken)).ConfigureAwait(false);
- }
- else
- {
- if (persistentClasses == null)
- throw new ArgumentNullException(nameof(persistentClasses));
- foreach (var @class in persistentClasses)
- {
- await (factory.EvictAsync(@class, cancellationToken)).ConfigureAwait(false);
- }
- }
- }
- /// <summary>
- /// Evict all entries from the second-level cache. This method occurs outside
- /// of any transaction; it performs an immediate "hard" remove, so does not respect
- /// any transaction isolation semantics of the usage strategy. Use with care.
- /// </summary>
- /// <param name="factory">The session factory.</param>
- /// <param name="entityNames">The names of the entities to evict.</param>
- /// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param>
- public static async Task EvictEntityAsync(this ISessionFactory factory, IEnumerable<string> entityNames, CancellationToken cancellationToken = default(CancellationToken))
- {
- cancellationToken.ThrowIfCancellationRequested();
- if (factory is SessionFactoryImpl sfi)
- {
- await (sfi.EvictEntityAsync(entityNames, cancellationToken)).ConfigureAwait(false);
- }
- else
- {
- if (entityNames == null)
- throw new ArgumentNullException(nameof(entityNames));
- foreach (var name in entityNames)
- {
- await (factory.EvictEntityAsync(name, cancellationToken)).ConfigureAwait(false);
- }
- }
- }
- /// <summary>
- /// Evict all entries from the process-level cache. This method occurs outside
- /// of any transaction; it performs an immediate "hard" remove, so does not respect
- /// any transaction isolation semantics of the usage strategy. Use with care.
- /// </summary>
- /// <param name="factory">The session factory.</param>
- /// <param name="roleNames">The names of the collections to evict.</param>
- /// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param>
- public static async Task EvictCollectionAsync(this ISessionFactory factory, IEnumerable<string> roleNames, CancellationToken cancellationToken = default(CancellationToken))
- {
- cancellationToken.ThrowIfCancellationRequested();
- if (factory is SessionFactoryImpl sfi)
- {
- await (sfi.EvictCollectionAsync(roleNames, cancellationToken)).ConfigureAwait(false);
- }
- else
- {
- if (roleNames == null)
- throw new ArgumentNullException(nameof(roleNames));
- foreach (var role in roleNames)
- {
- await (factory.EvictCollectionAsync(role, cancellationToken)).ConfigureAwait(false);
- }
- }
- }
- }
- public partial interface ISessionFactory : IDisposable
- {
- /// <summary>
- /// Destroy this <c>SessionFactory</c> and release all resources
- /// connection pools, etc). It is the responsibility of the application
- /// to ensure that there are no open <c>Session</c>s before calling
- /// <c>close()</c>.
- /// </summary>
- /// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param>
- Task CloseAsync(CancellationToken cancellationToken = default(CancellationToken));
- /// <summary>
- /// Evict all entries from the process-level cache. This method occurs outside
- /// of any transaction; it performs an immediate "hard" remove, so does not respect
- /// any transaction isolation semantics of the usage strategy. Use with care.
- /// </summary>
- /// <param name="persistentClass"></param>
- /// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param>
- Task EvictAsync(System.Type persistentClass, CancellationToken cancellationToken = default(CancellationToken));
- /// <summary>
- /// Evict an entry from the process-level cache. This method occurs outside
- /// of any transaction; it performs an immediate "hard" remove, so does not respect
- /// any transaction isolation semantics of the usage strategy. Use with care.
- /// </summary>
- /// <param name="persistentClass"></param>
- /// <param name="id"></param>
- /// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param>
- Task EvictAsync(System.Type persistentClass, object id, CancellationToken cancellationToken = default(CancellationToken));
- /// <summary>
- /// Evict all entries from the second-level cache. This method occurs outside
- /// of any transaction; it performs an immediate "hard" remove, so does not respect
- /// any transaction isolation semantics of the usage strategy. Use with care.
- /// </summary>
- Task EvictEntityAsync(string entityName, CancellationToken cancellationToken = default(CancellationToken));
- /// <summary>
- /// Evict an entry from the second-level cache. This method occurs outside
- /// of any transaction; it performs an immediate "hard" remove, so does not respect
- /// any transaction isolation semantics of the usage strategy. Use with care.
- /// </summary>
- Task EvictEntityAsync(string entityName, object id, CancellationToken cancellationToken = default(CancellationToken));
- /// <summary>
- /// Evict all entries from the process-level cache. This method occurs outside
- /// of any transaction; it performs an immediate "hard" remove, so does not respect
- /// any transaction isolation semantics of the usage strategy. Use with care.
- /// </summary>
- /// <param name="roleName"></param>
- /// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param>
- Task EvictCollectionAsync(string roleName, CancellationToken cancellationToken = default(CancellationToken));
- /// <summary>
- /// Evict an entry from the process-level cache. This method occurs outside
- /// of any transaction; it performs an immediate "hard" remove, so does not respect
- /// any transaction isolation semantics of the usage strategy. Use with care.
- /// </summary>
- /// <param name="roleName"></param>
- /// <param name="id"></param>
- /// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param>
- Task EvictCollectionAsync(string roleName, object id, CancellationToken cancellationToken = default(CancellationToken));
- /// <summary>
- /// Evict any query result sets cached in the default query cache region.
- /// </summary>
- /// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param>
- Task EvictQueriesAsync(CancellationToken cancellationToken = default(CancellationToken));
- /// <summary>
- /// Evict any query result sets cached in the named query cache region.
- /// </summary>
- /// <param name="cacheRegion"></param>
- /// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param>
- Task EvictQueriesAsync(string cacheRegion, CancellationToken cancellationToken = default(CancellationToken));
- }
- }