// // DoGetSchemaItems + support methods // #region protected override IEnumerable<DBSchemaItemRef> DoGetSchemaItems(DBSchemaTypes types) protected override IEnumerable <DBSchemaItemRef> DoGetSchemaItems(DBSchemaTypes types) { List <DBSchemaItemRef> items = new List <DBSchemaItemRef>(); using (DbConnection con = this.Database.CreateConnection()) { con.Open(); if (IsSchemaType(types, DBSchemaTypes.Table)) { this.LoadTableRefs(con, items); } if (IsSchemaType(types, DBSchemaTypes.View)) { this.LoadViewRefs(con, items); } if (IsSchemaType(types, DBSchemaTypes.Index)) { this.LoadIndexRefs(con, items); } if (IsSchemaType(types, DBSchemaTypes.StoredProcedure)) { this.LoadSprocRefs(con, items); } } return(items); }
public override void BeginCheckExists(DBSchemaTypes type, string owner, string name) { if (type == DBSchemaTypes.StoredProcedure) { throw new NotSupportedException(string.Format(Errors.DatabaseEngineDoesntSupportType, type)); } }
public override void BeginCreate(DBSchemaTypes type, string owner, string name, string options, bool checknotexists) { if (type == DBSchemaTypes.StoredProcedure) { throw new NotSupportedException(string.Format(Errors.DatabaseEngineDoesntSupportType, type)); } bool isconstraint = this.IsConstraintType(type); if (isconstraint && !string.IsNullOrEmpty(name)) { this.WriteRawSQLString("CONSTRAINT "); this.BeginIdentifier(); this.WriteObjectName(name); this.EndIdentifier(); this.WriteSpace(); } this.BeginCreate(type, options); if (checknotexists) { this.WriteCheckNotExists(type, owner, name); } if (!isconstraint) { this.WriteSourceTable(owner, name, string.Empty); } }
public override void BeginCreate(DBSchemaTypes type, string owner, string name, string options, bool checknotexists) { if (type == DBSchemaTypes.StoredProcedure) { throw new NotSupportedException(string.Format(Errors.DatabaseEngineDoesntSupportType, type)); } if (checknotexists) { throw new InvalidOperationException(String.Format(Errors.DBDoesntSupportIfExistsForThisType, "MS Access", type)); } if (type == DBSchemaTypes.ForeignKey && !string.IsNullOrEmpty(name)) { this.WriteRawSQLString("CONSTRAINT "); this.BeginIdentifier(); this.WriteObjectName(name); this.EndIdentifier(); this.WriteSpace(); } this.BeginCreate(type, options); if (checknotexists) { base.EndCheckNotExists(type, owner, name); } if (type != DBSchemaTypes.ForeignKey) { this.WriteSourceTable(owner, name, string.Empty); } }
public override void BeginCheckNotExists(DBSchemaTypes type, string owner, string name) { if (type == DBSchemaTypes.Index || type == DBSchemaTypes.View) { throw new ArgumentOutOfRangeException("checknotexisits", string.Format(Errors.DBDoesntSupportIfExistsForThisType, "MySQL", type)); } }
// // .ctor // #region internal protected DBDatabaseProperties(...) /// <summary> /// Creates a new instance of the DBDatabaseProperties /// </summary> /// <param name="databaseName"></param> /// <param name="productName"></param> /// <param name="productLevel"></param> /// <param name="serverEdition"></param> /// <param name="parameterFormat"></param> /// <param name="version"></param> /// <param name="supports"></param> /// <param name="caseSensitive"></param> /// <param name="layout"></param> /// <param name="supportedDbTypes"></param> /// <param name="supportedTopTypes"></param> internal protected DBDatabaseProperties(string databaseName, string productName, string productLevel, string serverEdition, string parameterFormat, Version version, DBSchemaTypes supports, bool caseSensitive, DBParameterLayout layout, System.Data.DbType[] supportedDbTypes, TopType[] supportedTopTypes, Schema.DBSchemaInformation schemaInfo, TypedOperationCollection unsupportedOps) { this._vers = version; this._edition = serverEdition; this._productlevel = productLevel; this._name = productName; this._paramformat = parameterFormat; this.SupportedSchemas = supports; this.CaseSensitiveNames = caseSensitive; this.ParameterLayout = layout; this.SupportedDbTypes = supportedDbTypes; this.SupportedTopTypes = supportedTopTypes; this._schemainfo = schemaInfo; this._unsupportedOps = unsupportedOps; }
/// <summary> /// Creates a new schema item with the specified values /// </summary> /// <param name="type"></param> /// <param name="schema"></param> /// <param name="name"></param> public DBSchemaItemRef(DBSchemaTypes type, string schema, string name) : this(type, string.Empty, schema, name) { this.Type = type; this.Schema = schema; this.Name = name; }
/// <summary> /// Creates a new schema item with the specified values /// </summary> /// <param name="type"></param> /// <param name="catalog"></param> /// <param name="schema"></param> /// <param name="name"></param> public DBSchemaItemRef(DBSchemaTypes type, string catalog, string schema, string name) { this.Type = type; this.Catalog = catalog; this.Schema = schema; this.Name = name; }
// // public properties // #region public DBSchemaItem this[DBSchemaTypes type, string owner, string name] {get;} /// <summary> /// Gets the specifed DBSchemaItem in this collection that /// has the type, owner and name specified /// </summary> /// <param name="type"></param> /// <param name="owner"></param> /// <param name="name"></param> /// <returns></returns> public DBSchemaItem this[DBSchemaTypes type, string owner, string name] { get { DBSchemaItemRef iref = new DBSchemaItemRef(type, owner, name); return(this[iref]); } }
/// <summary> /// Calculates and returns the integer hashcode which /// should be unique for any combination of type and operation /// </summary> /// <param name="type"></param> /// <param name="op"></param> /// <returns></returns> public static int GetHashCode(DBSchemaTypes type, DBSchemaOperation op) { int val = (int)type; val = val << 16; val += (int)op; return(val); }
public DBSchemaInfoLookup GetListLookup(DBSchemaTypes type) { DBSchemaInfoLookup value; if (!_listlookup.TryGetValue(type, out value)) { value = null; } return(value); }
public override void EndCreate(DBSchemaTypes type, bool checknotexists) { if (type == DBSchemaTypes.Table) { this.WriteRawSQLString(" ENGINE = "); this.WriteObjectName(this.TableEngine); } this.DecrementStatementDepth(); }
public override void EndCreate(DBSchemaTypes type, bool checknotexists) { //Special case where the CREATE VIEW .. AS cannot have parenthese after - causes exception if (type == DBSchemaTypes.View) { this.IncrementStatementDepth(); } base.EndCreate(type, checknotexists); }
/// <summary> /// Extends to support SEQUENCEs /// </summary> /// <param name="type"></param> protected override void WriteDropType(DBSchemaTypes type) { if (type == DBSchemaTypes.Sequence) { this.WriteDropType("SEQUENCE"); } else { base.WriteDropType(type); } }
/// <summary> /// Check if this database supports a specific operation on the database. /// </summary> /// <param name="schema"></param> /// <param name="op"></param> /// <returns></returns> public bool CheckSupports(DBSchemaTypes schema, DBSchemaOperation op) { if (this.UnsupportedOps.Contains(schema, op)) { return(false); } else { return(CheckSupports(schema)); } }
/// <summary> /// Extends to Support SEQUENCEs /// </summary> /// <param name="type"></param> /// <param name="options"></param> /// <param name="isconstraint"></param> protected override void WriteCreateType(DBSchemaTypes type, string options, bool isconstraint) { if (type == DBSchemaTypes.Sequence) { string native = "SEQUENCE"; this.WriteCreateType(native, options, isconstraint); } else { base.WriteCreateType(type, options, isconstraint); } }
public override void BeginDropStatement(DBSchemaTypes type, string owner, string name, bool checkExists) { if (type == DBSchemaTypes.StoredProcedure) { throw new NotSupportedException(string.Format(Errors.DatabaseEngineDoesntSupportType, type)); } if (checkExists) { throw new InvalidOperationException(String.Format(Errors.DBDoesntSupportIfExistsForThisType, "MS Access", type)); } base.BeginDropStatement(type, owner, name, checkExists); }
/// <summary> /// Returns true if this collection contains a TypedOperation that matches the parameters /// </summary> /// <param name="type"></param> /// <param name="operation"></param> /// <returns></returns> public bool Contains(DBSchemaTypes type, DBSchemaOperation operation) { TypedOperation value; int hash = TypedOperation.GetHashCode(type, operation); if (_ops.TryGetValue(hash, out value)) { return(true); } else { return(false); } }
// // public methods // #region public IEnumerable<DBSchemaItem> GetAllItemsOfType(DBSchemaTypes type) /// <summary> /// Gets All the DBSchemaItems in the collection that are the specified type /// </summary> /// <param name="type"></param> /// <returns></returns> public IEnumerable <DBSchemaItem> GetAllItemsOfType(DBSchemaTypes type) { List <DBSchemaItem> list = new List <DBSchemaItem>(); foreach (DBSchemaItem item in this) { if ((item.Type & type) > 0) { list.Add(item); } } return(list.AsReadOnly()); }
public override void BeginCreate(DBSchemaTypes type, string options) { if (type == DBSchemaTypes.StoredProcedure) { throw new NotSupportedException(string.Format(Errors.DatabaseEngineDoesntSupportType, type)); } base.BeginCreate(type, options); //Special case where the CREATE VIEW .. AS cannot have parenthese after - causes exception if (type == DBSchemaTypes.View) { this.DecrementStatementDepth(); } }
private void FillSchema(Dictionary <string, Dictionary <DBSchemaTypes, List <DBSchemaItemRef> > > byschema) { Dictionary <DBSchemaTypes, List <DBSchemaItemRef> > schema; List <DBSchemaItemRef> items = new List <DBSchemaItemRef>(); IEnumerable <DBSchemaItemRef> tbls = FillAllReferencesAndReturnTables(items); foreach (DBSchemaItemRef item in items) { System.Diagnostics.Debug.WriteLine(item.ToString()); string schemaname; if (string.IsNullOrEmpty(item.Schema)) { schemaname = string.Empty; } else { schemaname = item.Schema; } if (byschema.TryGetValue(schemaname, out schema) == false) { schema = new Dictionary <DBSchemaTypes, List <DBSchemaItemRef> >(); byschema.Add(schemaname, schema); } DBSchemaTypes type = item.Type; List <DBSchemaItemRef> all; if (!schema.TryGetValue(type, out all)) { all = new List <DBSchemaItemRef>(); schema.Add(type, all); } all.Add(item); } foreach (Dictionary <DBSchemaTypes, List <DBSchemaItemRef> > package in byschema.Values) { foreach (List <DBSchemaItemRef> value in package.Values) { value.Sort(delegate(DBSchemaItemRef one, DBSchemaItemRef two) { return(one.Name.CompareTo(two.Name)); }); } } }
protected virtual void FillNotSupported(TypedOperationCollection all) { Array values = Enum.GetValues(typeof(DBSchemaOperation)); //We don't support databases DBSchemaTypes type = DBSchemaTypes.Database; foreach (DBSchemaOperation op in values) { all.Add(type, op); } //We don't support users type = DBSchemaTypes.User; foreach (DBSchemaOperation op in values) { all.Add(type, op); } //we don't support groups or roles type = DBSchemaTypes.Group; foreach (DBSchemaOperation op in values) { all.Add(type, op); } //can't create functions type = DBSchemaTypes.Function; foreach (DBSchemaOperation op in values) { if (op != DBSchemaOperation.Exec) { all.Add(type, op); } } //can't create sprocs type = DBSchemaTypes.StoredProcedure; foreach (DBSchemaOperation op in values) { if (op != DBSchemaOperation.Exec) { all.Add(type, op); } } }
public override void EndCreate(DBSchemaTypes type, bool checknotexists) { if (type == DBSchemaTypes.StoredProcedure) { throw new NotSupportedException(string.Format(Errors.DatabaseEngineDoesntSupportType, type)); } if (type != DBSchemaTypes.ForeignKey) { //Special case where the CREATE VIEW .. AS cannot have parenthese after - causes exception if (type == DBSchemaTypes.View) { this.IncrementStatementDepth(); } } base.EndCreate(type, checknotexists); }
//Drop overrides for the supported syntax - DROP .... IF EXISTS //Rather than the default IF EXISTS (SELECT FROM INFO SCHEMA) public override void BeginDropStatement(DBSchemaTypes type, string owner, string name, bool checkExists) { if (checkExists) { if (type == DBSchemaTypes.Index) { throw new ArgumentOutOfRangeException("checkExists", string.Format(Errors.DBDoesntSupportIfExistsForThisType, "MySQL", type)); } } this.BeginDropStatement(type); if (checkExists) { this.WriteCheckExists(type, owner, name); } this.WriteSourceTable(owner, name, string.Empty); }
public override void BeginDropStatement(DBSchemaTypes type, string owner, string name, bool checkExists) { if (type == DBSchemaTypes.StoredProcedure) { throw new NotSupportedException(string.Format(Errors.DatabaseEngineDoesntSupportType, type)); } this.BeginDropStatement(type); if (checkExists) { this.WriteCheckExists(type, owner, name); } this.WriteSourceTable(owner, name, string.Empty); if (type == DBSchemaTypes.Index) { _droppingIndex = true; } }
/// <summary> /// returns the index of the image in the ImageList based upon the schema type /// </summary> /// <param name="dBSchemaTypes"></param> /// <returns></returns> private int GetIconForType(DBSchemaTypes dBSchemaTypes) { int imgIndex; switch (dBSchemaTypes) { case DBSchemaTypes.Table: imgIndex = 0; break; case DBSchemaTypes.View: imgIndex = 3; break; case DBSchemaTypes.StoredProcedure: imgIndex = 5; break; case DBSchemaTypes.Function: imgIndex = 4; break; case DBSchemaTypes.Index: imgIndex = 1; break; case DBSchemaTypes.CommandScripts: imgIndex = 6; break; case DBSchemaTypes.ForeignKey: imgIndex = 2; break; default: imgIndex = -1; break; } return(imgIndex); }
public override void BeginCreate(DBSchemaTypes type, string owner, string name, string options, bool checknotexists) { if (checknotexists) { if (type == DBSchemaTypes.Index || type == DBSchemaTypes.View) { throw new ArgumentOutOfRangeException("checknotexisits", string.Format(Errors.DBDoesntSupportIfExistsForThisType, "MySQL", type)); } } bool isconstraint = IsConstraintType(type); if (isconstraint) { if (!string.IsNullOrEmpty(name)) { this.WriteRawSQLString("CONSTRAINT "); this.BeginIdentifier(); this.WriteObjectName(name); this.EndIdentifier(); this.WriteSpace(); } } this.BeginCreate(type, options); if (checknotexists) { this.WriteCheckNotExists(type, owner, name); } if (!this.IsConstraintType(type)) { this.WriteSourceTable(owner, name, string.Empty); } }
// // public methods // #region public bool CheckSupports(DBSchemaTypes schema) /// <summary> /// Returns true if the Database supports the required schema type /// </summary> /// <param name="schema">The schema type to check (can be multiple)</param> /// <returns>True if the schema type is supported</returns> public bool CheckSupports(DBSchemaTypes schema) { return((this.SupportedSchemas & schema) > 0); }
public override void EndCheckNotExists(DBSchemaTypes type, string owner, string name) { }
private void WriteCheckNotExists(DBSchemaTypes type, string owner, string name) { this.WriteRawSQLString(" IF NOT EXISTS "); }