コード例 #1
0
        protected virtual void Initializer(string connectionString, string tableName, ModelToTableMapper <T> mapper, IList <string> updateOf, DmlTriggerType dmlTriggerType, bool automaticDatabaseObjectsTeardown, string namingConventionForDatabaseObjects)
        {
            if (mapper != null && mapper.Count() == 0)
            {
                throw new ModelToTableMapperException("Empty mapper");
            }

            if (!dmlTriggerType.HasFlag(DmlTriggerType.Update) && !dmlTriggerType.HasFlag(DmlTriggerType.All))
            {
                if (updateOf != null && updateOf.Any())
                {
                    throw new DmlTriggerTypeException("updateOf parameter can be specified only if DmlTriggerType parameter contains DmlTriggerType.Update too, not for DmlTriggerType.Delete or DmlTriggerType.Insert only.");
                }
            }

            this.TraceLevel = TraceLevel.Off;

            CreateMirrorTable(connectionString, updateOf, tableName, namingConventionForDatabaseObjects);

            _connectionString                 = connectionString;
            _mapper                           = mapper ?? this.GetModelMapperFromColumnDataAnnotation();
            _updateOf                         = updateOf;
            _userInterestedColumns            = GetUserInterestedColumns(updateOf);
            _automaticDatabaseObjectsTeardown = automaticDatabaseObjectsTeardown;
            _dataBaseObjectsNamingConvention  = GeneratedataBaseObjectsNamingConvention(namingConventionForDatabaseObjects);
            _needsToCreateDatabaseObjects     = CheckIfNeedsToCreateDatabaseObjects();
            _dmlTriggerType                   = dmlTriggerType;
        }
コード例 #2
0
        protected TableDependency(
            string connectionString,
            string schemaName = null,
            string tableName  = null,
            IModelToTableMapper <T> mapper  = null,
            IUpdateOfModel <T> updateOf     = null,
            ITableDependencyFilter filter   = null,
            DmlTriggerType dmlTriggerType   = DmlTriggerType.All,
            bool executeUserPermissionCheck = true)
        {
            if (mapper?.Count() == 0)
            {
                throw new UpdateOfException("mapper parameter is empty.");
            }
            if (updateOf?.Count() == 0)
            {
                throw new UpdateOfException("updateOf parameter is empty.");
            }

            this.CheckIfConnectionStringIsValid(connectionString);
            this.CheckIfParameterlessConstructorExistsForModel();
            if (executeUserPermissionCheck)
            {
                this.CheckIfUserHasPermissions(connectionString);
            }

            _connectionString = connectionString;
            _tableName        = this.GetTableName(tableName);
            _schemaName       = this.GetSchemaName(schemaName);
            _server           = this.GetServerName(connectionString);
            _database         = this.GetDataBaseName(connectionString);

            this.CheckIfTableExists(connectionString);
            this.CheckRdbmsDependentImplementation(connectionString);

            var tableColumnList = this.GetTableColumnsList(connectionString);

            if (!tableColumnList.Any())
            {
                throw new TableWithNoColumnsException(tableName);
            }

            _mapper = mapper ?? this.GetModelMapperFromColumnDataAnnotation();
            this.CheckMapperValidity(tableColumnList);

            this.CheckUpdateOfCongruenceWithTriggerType(updateOf, dmlTriggerType);
            _updateOf = this.GetUpdateOfColumnNameList(updateOf, tableColumnList);

            _userInterestedColumns = this.GetUserInterestedColumns(tableColumnList);
            if (!_userInterestedColumns.Any())
            {
                throw new NoMatchBetweenModelAndTableColumns();
            }
            this.CheckIfUserInterestedColumnsCanBeManaged(_userInterestedColumns);

            _dataBaseObjectsNamingConvention = this.GetBaseObjectsNamingConvention();
            _dmlTriggerType = dmlTriggerType;
            _filter         = filter;
        }
 public SqlTableDependencyTest(
     string connectionString,
     string tableName  = null,
     string schemaName = null,
     IModelToTableMapper <T> mapper  = null,
     IUpdateOfModel <T> updateOf     = null,
     ITableDependencyFilter filter   = null,
     DmlTriggerType notifyOn         = DmlTriggerType.All,
     bool executeUserPermissionCheck = true,
     bool includeOldValues           = false,
     bool throwExceptionBeforeWaitForNotifications     = false,
     bool throwExceptionInWaitForNotificationsPoint1   = false,
     bool throwExceptionInWaitForNotificationsPoint2   = false,
     bool throwExceptionInWaitForNotificationsPoint3   = false,
     bool throwExceptionCreateSqlServerDatabaseObjects = false) : base(connectionString, tableName, schemaName, mapper, updateOf, filter, notifyOn, executeUserPermissionCheck, includeOldValues)
 {
     _throwExceptionBeforeWaitForNotifications     = throwExceptionBeforeWaitForNotifications;
     _throwExceptionInWaitForNotificationsPoint1   = throwExceptionInWaitForNotificationsPoint1;
     _throwExceptionInWaitForNotificationsPoint2   = throwExceptionInWaitForNotificationsPoint2;
     _throwExceptionInWaitForNotificationsPoint3   = throwExceptionInWaitForNotificationsPoint3;
     _throwExceptionCreateSqlServerDatabaseObjects = throwExceptionCreateSqlServerDatabaseObjects;
 }
コード例 #4
0
        protected virtual void CheckUpdateOfCongruenceWithTriggerType(IUpdateOfModel <T> updateOf, DmlTriggerType dmlTriggerType)
        {
            if (updateOf == null || updateOf.Count() == 0)
            {
                return;
            }

            if (!dmlTriggerType.HasFlag(DmlTriggerType.Update) && !dmlTriggerType.HasFlag(DmlTriggerType.All))
            {
                if (updateOf.Count() > 0)
                {
                    throw new DmlTriggerTypeException("updateOf parameter can be specified only if DmlTriggerType parameter contains DmlTriggerType.Update too, not for DmlTriggerType.Delete or DmlTriggerType.Insert only.");
                }
            }
        }
コード例 #5
0
 public SqlMonitor(string tableName, Expression <Func <T, bool> > filter = null, DmlTriggerType monitorType = DmlTriggerType.All)
 {
     tableDependency = new SqlTableDependency <T>(ConnectionStringInfo.Get(), tableName, filter: new SqlTableDependencyFilter <T>(filter), notifyOn: monitorType);
     tableDependency.Stop();
     tableDependency.OnChanged += Changed;
     tableDependency.OnError   += Error;
     tableDependency.Start();
 }
コード例 #6
0
 public SqlTableDependencyWithReconnection(string connectionString, string tableName = null, string schemaName = null, IModelToTableMapper <TEntity> mapper = null, IUpdateOfModel <TEntity> updateOf = null, ITableDependencyFilter filter = null, DmlTriggerType notifyOn = DmlTriggerType.All, bool executeUserPermissionCheck = true, bool includeOldValues = false)
     : base(connectionString, tableName, schemaName, mapper, updateOf, filter, notifyOn, executeUserPermissionCheck, includeOldValues)
 {
 }
コード例 #7
0
 protected TableDependency(string connectionString, string tableName, ModelToTableMapper <T> mapper, UpdateOfModel <T> updateOf, DmlTriggerType dmlTriggerType, bool automaticDatabaseObjectsTeardown, string namingConventionForDatabaseObjects = null)
 {
     this.TableDependencyCommonSettings(connectionString, tableName);
     this.Initializer(connectionString, tableName, mapper, this.GetColumnNameListFromUpdateOfModel(updateOf), dmlTriggerType, automaticDatabaseObjectsTeardown, namingConventionForDatabaseObjects);
 }
コード例 #8
0
 public DatabaseSubscription(IHubContext <THub> hubContext, DmlTriggerType notifyOn)
 {
     HubContext = hubContext;
     NotifyOn   = notifyOn;
 }
コード例 #9
0
ファイル: TableDependency.cs プロジェクト: imatary/work
 protected TableDependency(string connectionString, string tableName, ModelToTableMapper <T> mapper, UpdateOfModel <T> updateOf, DmlTriggerType dmlTriggerType)
 {
     this.TableDependencyCommonSettings(connectionString, tableName);
     this.Initializer(connectionString, tableName, mapper, this.GetColumnNameListFromUpdateOfModel(updateOf), dmlTriggerType);
 }
コード例 #10
0
ファイル: TableDependency.cs プロジェクト: imatary/work
 protected TableDependency(string connectionString, string tableName, ModelToTableMapper <T> mapper, IList <string> updateOf, DmlTriggerType dmlTriggerType)
 {
     this.TableDependencyCommonSettings(connectionString, tableName);
     this.Initializer(connectionString, tableName, mapper, updateOf, dmlTriggerType);
 }