/// <summary> /// Configures the context to connect to a in-memory database. /// </summary> /// <param name="source">The repository options builder.</param> /// <param name="ignoreTransactionWarning">If a transaction operation is requested, ignore any warnings since the in-memory provider does not support transactions.</param> /// <param name="ignoreSqlQueryWarning">If a SQL query is executed, ignore any warnings since the in-memory provider does not support SQL query execution.</param> /// <returns>The same builder instance.</returns> public static RepositoryOptionsBuilder UseInMemoryDatabase([NotNull] this RepositoryOptionsBuilder source, bool ignoreTransactionWarning = false, bool ignoreSqlQueryWarning = false) { Guard.NotNull(source, nameof(source)); source.UseInternalContextFactory(new InMemoryRepositoryContextFactory(ignoreTransactionWarning, ignoreSqlQueryWarning)); return(source); }
/// <summary> /// Configures the context to use entity framework using an IOC container to resolve the <typeparamref name="TDbContext"/>. /// </summary> /// <param name="source">The repository options builder.</param> /// <returns>The same builder instance.</returns> public static RepositoryOptionsBuilder UseEntityFramework <TDbContext>([NotNull] this RepositoryOptionsBuilder source) where TDbContext : DbContext { Guard.NotNull(source, nameof(source)); source.UseInternalContextFactory(new EfRepositoryContextFactory <TDbContext>()); return(source); }
/// <summary> /// Configures the context to use NHibernate. /// </summary> /// <param name="source">The repository options builder.</param> /// <returns>The same builder instance.</returns> /// <remarks> /// Configure NHibernate using the <c><hibernate-configuration></c> section /// from the application config file, if found, or the file <c>hibernate.cfg.xml</c> if the /// <c><hibernate-configuration></c> section not include the session-factory configuration. /// </remarks> public static RepositoryOptionsBuilder UseNHibernate([NotNull] this RepositoryOptionsBuilder source) { Guard.NotNull(source, nameof(source)); source.UseInternalContextFactory(new NHibernateRepositoryContextFactory()); return(source); }
/// <summary> /// Configures the context to use the azure storage blob service with a connection string. /// </summary> /// <param name="source">The repository options builder.</param> /// <param name="nameOrConnectionString">Either the database name or a connection string.</param> /// <param name="createIfNotExists">Creates the container if it does not exist.</param> /// <returns>The same builder instance.</returns> public static RepositoryOptionsBuilder UseAzureStorageBlob([NotNull] this RepositoryOptionsBuilder source, [NotNull] string nameOrConnectionString, bool createIfNotExists = false) { Guard.NotNull(source, nameof(source)); Guard.NotEmpty(nameOrConnectionString, nameof(nameOrConnectionString)); source.UseInternalContextFactory(new AzureStorageBlobRepositoryContextFactory(nameOrConnectionString, createIfNotExists)); return(source); }
/// <summary> /// Configures the context to use entity framework with a connection string. /// </summary> /// <param name="source">The repository options builder.</param> /// <param name="nameOrConnectionString">Either the database name or a connection string.</param> /// <returns>The same builder instance.</returns> public static RepositoryOptionsBuilder UseEntityFramework <TDbContext>([NotNull] this RepositoryOptionsBuilder source, [NotNull] string nameOrConnectionString) where TDbContext : DbContext { Guard.NotNull(source, nameof(source)); Guard.NotEmpty(nameOrConnectionString, nameof(nameOrConnectionString)); source.UseInternalContextFactory(new EfRepositoryContextFactory <TDbContext>(nameOrConnectionString)); return(source); }
/// <summary> /// Configures the context to connect to a named XML formatted database. /// </summary> /// <param name="source">The repository options builder.</param> /// <param name="path">The database directory to create.</param> /// <param name="ignoreTransactionWarning">If a transaction operation is requested, ignore any warnings since the context provider does not support transactions.</param> /// <param name="ignoreSqlQueryWarning">If a SQL query is executed, ignore any warnings since the in-memory provider does not support SQL query execution.</param> /// <returns>The same builder instance.</returns> public static RepositoryOptionsBuilder UseXmlDatabase([NotNull] this RepositoryOptionsBuilder source, [NotNull] string path, bool ignoreTransactionWarning = false, bool ignoreSqlQueryWarning = false) { Guard.NotNull(source, nameof(source)); Guard.NotEmpty(path, nameof(path)); source.UseInternalContextFactory(new XmlRepositoryContextFactory(path, ignoreTransactionWarning, ignoreSqlQueryWarning)); return(source); }
/// <summary> /// Configures the context to use ado.net with an existing connection. /// </summary> /// <param name="source">The repository options builder.</param> /// <param name="existingConnection">The existing connection.</param> /// <param name="ensureDatabaseCreated"> /// Ensures that the database for the context exists. If it exists, no action is taken. /// If it does not exist then the database and all its schema are created. /// If the database exists, then no effort is made to ensure it is compatible with the model for this context. /// </param> /// <returns>The same builder instance.</returns> public static RepositoryOptionsBuilder UseAdoNet([NotNull] this RepositoryOptionsBuilder source, [NotNull] DbConnection existingConnection, bool ensureDatabaseCreated = false) { Guard.NotNull(source, nameof(source)); Guard.NotNull(existingConnection, nameof(existingConnection)); source.UseInternalContextFactory(new AdoNetRepositoryContextFactory(existingConnection, ensureDatabaseCreated)); return(source); }
/// <summary> /// Configures the context to use ado.net with a connection string. /// </summary> /// <param name="source">The repository options builder.</param> /// <param name="nameOrConnectionString">Either the database name or a connection string.</param> /// <param name="ensureDatabaseCreated"> /// Ensures that the database for the context exists. If it exists, no action is taken. /// If it does not exist then the database and all its schema are created. /// If the database exists, then no effort is made to ensure it is compatible with the model for this context. /// </param> /// <returns>The same builder instance.</returns> public static RepositoryOptionsBuilder UseAdoNet([NotNull] this RepositoryOptionsBuilder source, [NotNull] string nameOrConnectionString, bool ensureDatabaseCreated = false) { Guard.NotNull(source, nameof(source)); Guard.NotEmpty(nameOrConnectionString, nameof(nameOrConnectionString)); source.UseInternalContextFactory(new AdoNetRepositoryContextFactory(nameOrConnectionString, ensureDatabaseCreated)); return(source); }
/// <summary> /// Configures the context to use the azure storage blob service with a connection string. /// </summary> /// <param name="source">The repository options builder.</param> /// <param name="connectionString">The connection string.</param> /// <param name="createIfNotExists">Creates the container if it does not exist.</param> /// <param name="serializerSettings">The serializer options to use when serializing to JSON.</param> /// <returns>The same builder instance.</returns> public static RepositoryOptionsBuilder UseAzureStorageBlob([NotNull] this RepositoryOptionsBuilder source, [NotNull] string connectionString, bool createIfNotExists = false, JsonSerializerSettings serializerSettings = null) { Guard.NotNull(source, nameof(source)); Guard.NotEmpty(connectionString, nameof(connectionString)); source.UseInternalContextFactory( new AzureStorageBlobRepositoryContextFactory(connectionString, createIfNotExists, serializerSettings)); return(source); }