Example #1
0
 public Table(Schema schema, String name, Boolean isView)
     : base()
 {
     this.Schema = schema;
     this.Name   = IdentifierHelper.GetStrippedSqlIdentifier(name);
     this.IsView = isView;
 }
Example #2
0
 public Table(Schema schema, String name, TableType tableType)
     : base()
 {
     this.Schema    = schema;
     this.Name      = IdentifierHelper.GetStrippedSqlIdentifier(name);
     this.TableType = tableType;
 }
Example #3
0
 public Schema(Database database, String name, Boolean isDefaultSchema)
     : base()
 {
     this.Database         = database;
     this.Name             = IdentifierHelper.GetStrippedSqlIdentifier(name);
     this.IsDefaultSchema  = isDefaultSchema;
     this.StoredProcedures = new List <StoredProcedure>();
 }
Example #4
0
        public Database(Server server, String name)
            : base()
        {
            this.Server = server;
            this.Name   = IdentifierHelper.GetStrippedSqlIdentifier(name);

            this._connection = this.Server.Configuration.Connection;
        }
Example #5
0
        public StoredProcedure(Schema schema, String name, Int32 versionNumber, SqlParameter[] sqlParameters)
            : this()
        {
            this.Schema              = schema;
            this.Name                = IdentifierHelper.GetStrippedSqlIdentifier(name);
            this.VersionNumber       = versionNumber;
            this.SqlParameters       = sqlParameters;
            this.DoesReturnResultSet = true;

            this._configuration = this.Schema.Database.Server.Configuration;
        }
Example #6
0
        /// <summary>
        /// Create and add a StoredProcedure instance to this Database.
        /// <para>The name parameter must be a valid one-part or two-part T-SQL identifier.  Square brackets around the name parts are optional.</para>
        /// <para>E.g. "my_stored_proc", "[my_stored_proc]", "my_schema.my_stored_proc", and "[my_schema].[my_stored_proc]" are all valid name identifiers.</para>
        /// <para>Names with more than two parts, or missing parts, are considered errors.</para>
        /// </summary>
        public StoredProcedure AddStoredProcedure(String name, Int32 versionNumber, params SqlParameter[] sqlParameters)
        {
            name.Name("name").NotNullEmptyOrOnlyWhitespace();
            versionNumber.Name("versionNumber").GreaterThan(0);

            name = IdentifierHelper.GetStrippedSqlIdentifier(name);
            var nameParts = name.Split(".".ToCharArray(), StringSplitOptions.None);

            /* It's an error if any of the name parts are empty,
             * and this method only accepts one-part ([object name]) or
             * two-part ([schema name].[object name]) T-SQL identifiers. */
            if (nameParts.Any(s => s.IsEmpty()) || (nameParts.Length > 2))
            {
                throw new ArgumentExceptionFmt(Properties.Resources.InvalidStoredProcedureName, name);
            }

            /* At this point, all of the name parts have been validated for correct form. */

            if (nameParts.Length == 1)
            {
                return(this.Schemas.GetDefaultSchema().AddStoredProcedure(name, versionNumber, sqlParameters));
            }
            else
            {
                var schemaName = nameParts[0];
                var schema     = this.Schemas.GetByName(schemaName);
                if (schema == null)
                {
                    throw new ExceptionFmt(Properties.Resources.SchemaNameNotFound, schemaName);
                }

                var storedProcedureName = nameParts[1];

                return(schema.AddStoredProcedure(storedProcedureName, versionNumber, sqlParameters));
            }
        }