与 Microsoft.SqlServer.DACFx 相比,如何排除架构中的 SQL 对象?

问题描述

在与“排除”-方法 (https://docs.microsoft.com/en-us/dotnet/api/microsoft.sqlserver.dac.compare.schemacomparisonresult.exclude?view=sql-dacfx-150) 进行比较后,我尝试排除 sql 对象。问题在于,该方法非常慢(我想排除 183 个对象)。

然后我想在比较对象之前排除它们。我用这个代码做到了(源数据库的例子。我对目标数据库做同样的事情):

List<TSqlObject> sourceModel = TSqlModel.LoadFromDatabase(options.sourceConnectionString).GetObjects(DacQueryScopes.All).ToList();

               
                var objects2Include = getListOfObjects();
                var excludedObjects = sourceModel.Where(o => String.Join(".",o.Name.Parts) == "dbo.Persons").ToList();  


                   foreach (TSqlObject excludingObject in sourceModel)
                   {
                       string name = String.Join(".",excludingObject.Name.Parts);

                       if (!objects2Include.Contains(name))
                       {
                           comparison.ExcludedSourceObjects.Add(new SchemaComparisonExcludedObjectId(excludingObject.ObjectType,new ObjectIdentifier(excludingObject.Name.Parts.ToArray())));
                           
                       }
                   }

例如:最后(“差异”)总是有这个表“dbo.Persons”。但是这个对象在“excludedObjects”列表中。我还检查了它是否在名称为“dbo.Persons”(调试器)时进入“if”-Statement。确实如此。也没有错误或类似的东西。

在列表“objects2Include”中是我想要比较的对象。它是一个简单的字符串列表(如:"dbo.Persons","dbo.Test",...)

我做错了什么?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...