Ejemplo n.º 1
0
 public void Dispose()
 {
     if (this.model != null)
     {
         model.Dispose();
         model = null;
     }
 }
Ejemplo n.º 2
0
        protected void CreateModelUsingTestScripts()
        {
            TSqlModel scriptedModel = this.CreateScriptedModel();

            this.ModelForAnalysis = scriptedModel;
            if (this.Target == AnalysisTarget.DacpacModel)
            {
                this.ModelForAnalysis = this.CreateDacpacModel(scriptedModel);
                scriptedModel.Dispose();
            }

            this._trash.Add(this.ModelForAnalysis);
        }
Ejemplo n.º 3
0
        protected void CreateModelUsingTestScripts()
        {
            TSqlModel scriptedModel = CreateScriptedModel();

            ModelForAnalysis = scriptedModel;
            if (Target == AnalysisTarget.DacpacModel)
            {
                ModelForAnalysis = CreateDacpacModel(scriptedModel);
                scriptedModel.Dispose();
            }

            _trash.Add(ModelForAnalysis);
        }
Ejemplo n.º 4
0
        private void WriteFinalDacpac(TSqlModel model, string preScript, string postScript)
        {
            var metadata = new PackageMetadata();

            metadata.Name = "dacpac";

            DacPackageExtensions.BuildPackage(_targetPath, model, metadata);

            var writer = new HeaderWriter(_targetPath, new DacHacFactory());

            foreach (var customData in _globalHeaders)
            {
                writer.AddCustomData(customData);
            }
            writer.Close();

            AddScripts(preScript, postScript, _targetPath);
            model.Dispose();
        }
Ejemplo n.º 5
0
        protected void CreateModelUsingTestScripts()
        {
            switch (Target)
            {
            case AnalysisTarget.Database:
                ModelForAnalysis = CreateDatabaseModel();
                break;

            case AnalysisTarget.DacpacModel:
                TSqlModel scriptedModel = CreateScriptedModel();
                ModelForAnalysis = CreateDacpacModel(scriptedModel);
                scriptedModel.Dispose();
                break;

            default:
                ModelForAnalysis = CreateScriptedModel();
                break;
            }

            _trash.Add(ModelForAnalysis);
        }
Ejemplo n.º 6
0
        public void Remove(IEnumerable <string> objectNames)
        {
            var options  = SqlModel.CloneModelOptions();
            var newModel = new TSqlModel(SqlModel.Version, options);

            foreach (var obj in SqlModel.GetObjects(DacQueryScopes.UserDefined).Where(o => !o.Name.HasName || !objectNames.Contains(o.Name.ToString())))
            {
                if (obj.TryGetScript(out var script))
                {
                    newModel.AddObjects(script);
                }
                else
                {
                    _logger.Debug("Remove - Unable to get script from SQL object {Name} {Type}", obj.Name, obj.ObjectType.Name);
                }
            }

            lock (SqlModel)
            {
                SqlModel?.Dispose();
                SqlModel = newModel;
            }
        }
Ejemplo n.º 7
0
 public void Dispose()
 {
     first?.Dispose();
     target?.Dispose();
 }