示例#1
0
        /// <summary>
        /// Creates a new TSqlModel, loads all *.sql files specified in the SqlPaths property
        /// into the new model, and then parses the model.
        /// </summary>
        /// <exception cref="System.InvalidOperationException">No path to *.sql files exists in SqlPaths properties.</exception>
        public void LoadModel()
        {
            if (!this.SqlPaths.Any(x => !string.IsNullOrWhiteSpace(x)))
            {
                throw new InvalidOperationException("No path to *.sql files exists in SqlPaths properties.");
            }

            var procFiles = new List <string>();

            foreach (var sqlPath in this.SqlPaths)
            {
                if (sqlPath.EndsWith(".sql"))
                {
                    procFiles.Add(sqlPath);
                }
                else
                {
                    procFiles.AddRange(Directory.GetFiles(sqlPath, "*.sql", SearchOption.AllDirectories));
                }
            }

            var model = new dac.TSqlModel(_sqlServerVersion, new dac.TSqlModelOptions());

            foreach (var procFile in procFiles)
            {
                model.AddObjects(File.ReadAllText(procFile));
            }
            LoadModel(model);
        }
示例#2
0
        /// <summary>
        /// Creates a new TSqlModel, loads each specified sql statement into the new model,
        /// and then parses the model
        /// </summary>
        /// <param name="sqlStatements">One or more sql statements to load, such as CREATE TABLE or CREATE PROCEDURE statements.</param>
        public void LoadModel(params string[] sqlStatements)
        {
            var model = new dac.TSqlModel(_sqlServerVersion, new dac.TSqlModelOptions());

            foreach (var sqlStatement in sqlStatements)
            {
                model.AddObjects(sqlStatement);
            }
            LoadModel(model);
        }
示例#3
0
 /// <summary>
 /// Creates a new TSqlModel, loads each specified sql statement into the new model,
 /// and then parses the model
 /// </summary>
 /// <param name="sqlStatements">One or more sql statements to load, such as CREATE TABLE or CREATE PROCEDURE statements.</param>
 public void LoadModel(params string[] sqlStatements)
 {
     var model = new dac.TSqlModel(dac.SqlServerVersion.Sql100, new dac.TSqlModelOptions());
     foreach (var sqlStatement in sqlStatements)
     {
         model.AddObjects(sqlStatement);
     }
     LoadModel(model);
 }
示例#4
0
        /// <summary>
        /// Creates a new TSqlModel, loads all *.sql files specified in the SqlPaths property
        /// into the new model, and then parses the model.
        /// </summary>
        /// <exception cref="System.InvalidOperationException">No path to *.sql files exists in SqlPaths properties.</exception>
        public void LoadModel()
        {
            if (!this.SqlPaths.Any(x => !string.IsNullOrWhiteSpace(x)))
                throw new InvalidOperationException("No path to *.sql files exists in SqlPaths properties.");

            var procFiles = new List<string>();
            foreach (var sqlPath in this.SqlPaths)
            {
                if (sqlPath.EndsWith(".sql"))
                {
                    procFiles.Add(sqlPath);
                }
                else
                {
                    procFiles.AddRange(Directory.GetFiles(sqlPath, "*.sql", SearchOption.AllDirectories));
                }
            }

            var model = new dac.TSqlModel(dac.SqlServerVersion.Sql100, new dac.TSqlModelOptions());
            foreach (var procFile in procFiles)
            {
                model.AddObjects(File.ReadAllText(procFile));
            }
            LoadModel(model);
        }