private ImmutableArray <ConditionColumnSchema> GetConditionsSchema <TEntity>(object value) { var config = new MicroCRUDConfig(this.dialect, new TableSchemaFactory(new DefaultTableNameFactory(), new DefaultColumnNameFactory()), true); var tableSchema = TableSchemaFactory.GetTableSchema(typeof(TEntity), config.Dialect, config.SchemaFactory); return(TableSchemaFactory.GetConditionsSchema(typeof(TEntity), tableSchema, value.GetType(), config.Dialect, config.SchemaFactory)); }
public MakeCreateTempTableStatement() { MicroCRUDConfig.AddTypeMap(typeof(DateTime), DbType.DateTime2); this.tableNameFactory = new Mock <ITableNameFactory>(); var defaultTableNameFactory = new DefaultTableNameFactory(); this.tableNameFactory.Setup(f => f.GetTableName(It.IsAny <Type>(), It.IsAny <IDialect>())) .Returns((Type type, IDialect d) => "[#" + defaultTableNameFactory.GetTableName(type, d).Substring(1)); }
protected CreateTempTableAndInsert(DatabaseFixture fixture) : base(fixture) { var defaultFactory = new DefaultTableNameFactory(); this.tableNameFactory = new Mock <ITableNameFactory>(); this.tableNameFactory.Setup(f => f.GetTableName(It.IsAny <Type>(), It.IsAny <IDialect>())) .Returns((Type t, IDialect d) => GetTableName(defaultFactory, t, d)); MicroCRUDConfig.SetTableNameFactory(this.tableNameFactory.Object); }
public void Can_set_ColumnNameFactory() { // Act try { MicroCRUDConfig.SetColumnNameFactory(new DefaultColumnNameFactory()); } finally { MicroCRUDConfig.SetColumnNameFactory(new DefaultColumnNameFactory()); } }
public void Can_set_TableNameFactory() { // Act try { MicroCRUDConfig.SetTableNameFactory(new NonPluralizingTableNameFactory()); } finally { MicroCRUDConfig.SetTableNameFactory(new DefaultTableNameFactory()); } }
/// <summary> /// Creates a command which will delete an entity by usings it's primary key. /// </summary> public static CommandDefinition MakeDeleteCommand <TEntity>( object entity, IDbTransaction transaction, IDialect dialect, int?commandTimeout, MicroCRUDConfig config, CancellationToken cancellationToken = default(CancellationToken)) { Ensure.NotNull(entity, nameof(entity)); dialect = dialect ?? config.Dialect; var tableSchema = TableSchemaFactory.GetTableSchema(typeof(TEntity), dialect, config.SchemaFactory); var sql = dialect.MakeDeleteByPrimaryKeyStatement(tableSchema); return(MakeCommandDefinition(sql, entity, transaction, commandTimeout, cancellationToken)); }
public void Throws_exception_if_current_is_set_to_null() { // Act Assert.Throws <ArgumentException>(() => MicroCRUDConfig.SetCurrent(c => null)); }
public void Dispose() { MicroCRUDConfig.SetTableNameFactory(new DefaultTableNameFactory()); }