当前位置: 首页>>代码示例>>C#>>正文


C# IReadOnlyCollection.OfType方法代码示例

本文整理汇总了C#中IReadOnlyCollection.OfType方法的典型用法代码示例。如果您正苦于以下问题:C# IReadOnlyCollection.OfType方法的具体用法?C# IReadOnlyCollection.OfType怎么用?C# IReadOnlyCollection.OfType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IReadOnlyCollection的用法示例。


在下文中一共展示了IReadOnlyCollection.OfType方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExecuteCommands

        public IReadOnlyCollection<IEvent> ExecuteCommands(IReadOnlyCollection<ICommand> commands)
        {
            if (commands.OfType<DropViewsCommand>().Any())
            {
                var database = _sqlConnection.GetDatabase();
                var views = database.Views.Cast<View>().Where(v => v != null && !v.IsSystemObject).ToArray();

                var viewsToRestore = new List<StringCollection>();
                foreach (var view in views)
                {
                    viewsToRestore.Add(view.Script());
                    view.Drop();
                }

                return new[] { new ViewsDroppedEvent(viewsToRestore) };
            }

            var restoreViewsCommand = commands.OfType<RestoreViewsCommand>().SingleOrDefault();
            if (restoreViewsCommand != null)
            {
                foreach (var view in restoreViewsCommand.ViewsToRestore)
                {
                    foreach (var script in view)
                    {
                        var command = new SqlCommand(script, _sqlConnection) { CommandTimeout = _commandTimeout };
                        command.ExecuteNonQuery();
                    }
                }
            }

            return Array.Empty<IEvent>();
        }
开发者ID:2gis,项目名称:nuclear-river,代码行数:32,代码来源:ViewManagementActor.cs

示例2: ExecuteCommands

        public IReadOnlyCollection<IEvent> ExecuteCommands(IReadOnlyCollection<ICommand> commands)
        {
            if (commands.OfType<DisableConstraintsCommand>().Any())
            {
                var tables = GetTables();

                var checks = tables.SelectMany(x => x.Checks.Cast<Check>()).ToArray();
                var checksToRestore = new List<StringCollection>();
                foreach (var check in checks)
                {
                    checksToRestore.Add(check.Script());
                    check.Drop();
                }

                var foreignKeys = tables.SelectMany(x => x.ForeignKeys.Cast<ForeignKey>()).ToArray();
                var foreignKeysToRestore = new List<StringCollection>();
                foreach (var foreignKey in foreignKeys)
                {
                    foreignKeysToRestore.Add(foreignKey.Script());
                    foreignKey.Drop();
                }

                return new[] { new ConstraintsDisabledEvent(checksToRestore, foreignKeysToRestore) };
            }

            var enableCommand = commands.OfType<EnableConstraintsCommand>().SingleOrDefault();
            if (enableCommand != null)
            {
                foreach (var check in enableCommand.ChecksToRestore)
                {
                    foreach (var script in check)
                    {
                        var command = new SqlCommand(script, _sqlConnection) { CommandTimeout = _commandTimeout };
                        command.ExecuteNonQuery();
                    }
                }

                foreach (var foreinKey in enableCommand.ForeignKeysToRestore)
                {
                    foreach (var script in foreinKey)
                    {
                        var command = new SqlCommand(script, _sqlConnection) { CommandTimeout = _commandTimeout };
                        command.ExecuteNonQuery();
                    }
                }
            }

            return Array.Empty<IEvent>();
        }
开发者ID:2gis,项目名称:nuclear-river,代码行数:49,代码来源:ConstraintsManagementActor.cs

示例3: ExecuteCommands

        public IReadOnlyCollection<IEvent> ExecuteCommands(IReadOnlyCollection<ICommand> commands)
        {
            var command = commands.OfType<TruncateTableCommand>().SingleOrDefault();
            if (command != null)
            {
                ExecuteTruncate(command.Table);
            }

            return Array.Empty<IEvent>();
        }
开发者ID:2gis,项目名称:nuclear-river,代码行数:10,代码来源:TruncateTableActor.cs

示例4: ExecuteCommands

        public IReadOnlyCollection<IEvent> ExecuteCommands(IReadOnlyCollection<ICommand> commands)
        {
            var enableCommand = commands.OfType<EnableIndexesCommand>().SingleOrDefault();
            if (enableCommand != null)
            {
                _indexManager.EnableIndexes(enableCommand.Table);
            }

            return Array.Empty<IEvent>();
        }
开发者ID:2gis,项目名称:nuclear-river,代码行数:10,代码来源:EnableIndexesActor.cs

示例5: ExecuteCommands

        public IReadOnlyCollection<IEvent> ExecuteCommands(IReadOnlyCollection<ICommand> commands)
        {
            var command = commands.OfType<UpdateTableStatisticsCommand>().SingleOrDefault();
            if (command == null)
            {
                return Array.Empty<IEvent>();
            }

            try
            {
                var database = _sqlConnection.GetDatabase();
                var table = string.IsNullOrEmpty(command.Table.Schema) ? database.Tables[command.Table.Table] : database.Tables[command.Table.Table, command.Table.Schema];
                table.UpdateStatistics();

                return Array.Empty<IEvent>();
            }
            catch (Exception ex)
            {
                throw new DataException($"Error occured while statistics updating for table {command.Table}", ex);
            }
        }
开发者ID:2gis,项目名称:nuclear-river,代码行数:21,代码来源:UpdateTableStatisticsActor.cs

示例6: BuildColumnExpression

        private Expression BuildColumnExpression(
            IReadOnlyCollection<Expression> projections,
            TableExpressionBase tableExpression,
            IProperty property,
            IQuerySource querySource)
        {
            Check.NotNull(property, nameof(property));

            if (projections.Count == 0)
            {
                return new ColumnExpression(
                    _relationalAnnotationProvider.For(property).ColumnName,
                    property,
                    tableExpression);
            }

            var aliasExpressions
                = projections
                    .OfType<AliasExpression>()
                    .Where(p => p.TryGetColumnExpression()?.Property == property)
                    .ToList();

            var aliasExpression
                = aliasExpressions.Count == 1
                    ? aliasExpressions[0]
                    : aliasExpressions.Last(ae => ae.TryGetColumnExpression().Table.QuerySource == querySource);

            return new ColumnExpression(
                aliasExpression.Alias ?? aliasExpression.TryGetColumnExpression().Name,
                property,
                tableExpression);
        }
开发者ID:491134648,项目名称:EntityFramework,代码行数:32,代码来源:IncludeExpressionVisitor.cs

示例7: BuildColumnExpression

        private Expression BuildColumnExpression(
            IReadOnlyCollection<Expression> projections,
            TableExpressionBase tableExpression,
            IProperty property)
        {
            Check.NotNull(property, nameof(property));

            if (projections.Count == 0)
            {
                return new ColumnExpression(
                    _queryCompilationContext.GetColumnName(property),
                    property,
                    tableExpression);
            }

            var matchingColumnExpression
                = projections
                    .OfType<AliasExpression>()
                    .Last(p => p.TryGetColumnExpression()?.Property == property);

            return new ColumnExpression(
                matchingColumnExpression.Alias ?? matchingColumnExpression.TryGetColumnExpression().Name,
                property,
                tableExpression);
        }
开发者ID:aishaloshik,项目名称:EntityFramework,代码行数:25,代码来源:IncludeExpressionTreeVisitor.cs

示例8: CreateSchemaChangesCompensationalCommands

        private static IReadOnlyCollection<ICommand> CreateSchemaChangesCompensationalCommands(IReadOnlyCollection<IEvent> events)
        {
            var commands = new List<ICommand>();

            var constraintsDisabledEvent = events.OfType<ConstraintsDisabledEvent>().SingleOrDefault();
            if (constraintsDisabledEvent != null)
            {
                commands.Add(new EnableConstraintsCommand(constraintsDisabledEvent.Checks, constraintsDisabledEvent.ForeignKeys));
            }

            var viewsDroppedEvent = events.OfType<ViewsDroppedEvent>().SingleOrDefault();
            if (viewsDroppedEvent != null)
            {
                commands.Add(new RestoreViewsCommand(viewsDroppedEvent.ViewsToRestore));
            }

            return commands;
        }
开发者ID:2gis,项目名称:nuclear-river,代码行数:18,代码来源:BulkReplicationActor.cs

示例9: HandleAia

 private IReadOnlyCollection<ILaunchableContent> HandleAia(
     IReadOnlyCollection<ILaunchableContent> content) {
     var info = new AiaInfo(content.OfType<IHavePackageName>().ToArray());
     var newModsList = content.ToList();
     if (info.HasAia() && info.HasCup()) {
         //    if (aiaSpecific != null || aiaSpecificLite != null)
         //      newModsList.Remove(Cup);
         //                else
         newModsList.RemoveAll(info.IsAia);
     }
     if (info.HasCup() || info.HasAia())
         newModsList.RemoveAll(info.IsA3Mp);
     return newModsList;
 }
开发者ID:SIXNetworks,项目名称:withSIX.Desktop,代码行数:14,代码来源:Arma3Game.cs


注:本文中的IReadOnlyCollection.OfType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。