示例#1
0
 public TableBuilder WithSchemaSynchronized(bool schemaSynchronized)
 {
     SynchronizationStrategy = schemaSynchronized
         ? SchemaSynchronizationStrategy.Ignore
         : SchemaSynchronizationStrategy.UntilSuccess;
     return(this);
 }
示例#2
0
        public Table(
            string name,
            string[] keyColumnsNames,
            IDictionary <string, SqlType> columns,
            string schema = null,
            SchemaSynchronizationStrategy synchronizationStrategy = SchemaSynchronizationStrategy.UntilSuccess)
        {
            if (keyColumnsNames == null)
            {
                throw new ArgumentNullException(nameof(keyColumnsNames));
            }
            _synchronizationStrategy = synchronizationStrategy;
            var repeatedKeyColumn = keyColumnsNames.GroupBy(k => k).FirstOrDefault(c => c.Count() > 1);

            if (repeatedKeyColumn != null)
            {
                throw new ArgumentException($"The key column named '{repeatedKeyColumn.Key}' appears more than once", nameof(columns));
            }
            if (columns == null)
            {
                throw new ArgumentNullException(nameof(columns));
            }
            if (columns.Count == 0)
            {
                throw new ArgumentException(@"The table must define at least one column", nameof(columns));
            }
            var repeatedColumn = columns.GroupBy(c => c.Key).FirstOrDefault(c => c.Count() > 1);

            if (repeatedColumn != null)
            {
                throw new ArgumentException($"The column named '{repeatedColumn.Key}' appears more than once", nameof(columns));
            }
            Name            = name ?? throw new ArgumentNullException(nameof(name));
            KeyColumnsNames = keyColumnsNames;
            Columns         = columns;
            Schema          = schema;
            _schemaSynchronizedSemaphore = new SemaphoreSlim(1);
        }
示例#3
0
 /// <summary>
 /// The synchronization strategy to be used with the table.
 /// </summary>
 /// <param name="synchronizationStrategy"></param>
 /// <returns></returns>
 public TableBuilder WithSynchronizationStrategy(SchemaSynchronizationStrategy synchronizationStrategy)
 {
     SynchronizationStrategy = synchronizationStrategy;
     return(this);
 }