Exemple #1
0
        protected internal override DBObject InternalResolveChildObject(DBObjectUrn childObjectUrn)
        {
            DBObject result = null;

            if (Util.StringEqual(childObjectUrn[ItemType], this.Name, true))
            {
                if (!string.IsNullOrEmpty(childObjectUrn.TableSchema))
                {
                    if (!Util.StringEqual(childObjectUrn.TableSchema, this.Owner.Name, true))
                    {
                        return(result);
                    }
                }

                result = this;

                string columnName = childObjectUrn[DbItemType.Column];
                if (!string.IsNullOrEmpty(columnName))
                {
                    Column columnObj = this.Columns.SingleOrDefault(column => Util.StringEqual(column.Name, columnName, true));
                    if (columnObj != null)
                    {
                        result = columnObj.InternalResolveChildObject(childObjectUrn);
                    }
                }
            }

            return(result);
        }
Exemple #2
0
        protected internal override DBObject InternalResolveChildObject(DBObjectUrn childObjectUrn)
        {
            DBObject result = null;

            if (Util.StringEqual(childObjectUrn[DbItemType.Database], this.Name, true))
            {
                result = this;

                string schemaName = childObjectUrn[DbItemType.Schema];
                if (!string.IsNullOrEmpty(schemaName))
                {
                    var schemaObj = this.Schemas.SingleOrDefault(delegate(Schema schema)
                    {
                        bool tableNameEquals = Util.StringEqual(schema.Name, schemaName, true);
                        if (!string.IsNullOrEmpty(childObjectUrn.TableSchema))
                        {
                            return(tableNameEquals && Util.StringEqual(schema.Name, childObjectUrn.TableSchema, true));
                        }

                        return(tableNameEquals);
                    });

                    if (schemaObj != null)
                    {
                        result = schemaObj.InternalResolveChildObject(childObjectUrn);
                    }
                }
            }

            return(result);
        }
Exemple #3
0
        protected internal override DBObject InternalResolveChildObject(DBObjectUrn childObjectUrn)
        {
            DBObject result = base.InternalResolveChildObject(childObjectUrn);

            if (result == null && Util.StringEqual(childObjectUrn[ItemType], this.Name, true))
            {
                result = this;

                string indexName = childObjectUrn[DbItemType.Index];
                if (!string.IsNullOrEmpty(indexName))
                {
                    Index indexObj = this.Indexes.SingleOrDefault(item => Util.StringEqual(item.Name, indexName, true));
                    if (indexObj != null)
                    {
                        result = indexObj.InternalResolveChildObject(childObjectUrn);
                    }
                }

                string foreignKeyName = childObjectUrn[DbItemType.ForeignKey];
                if (!string.IsNullOrEmpty(foreignKeyName))
                {
                    ForeignKey foreignKeyObj = this.ForeignKeys.SingleOrDefault(item => Util.StringEqual(item.Name, foreignKeyName, true));
                    if (foreignKeyObj != null)
                    {
                        result = foreignKeyObj.InternalResolveChildObject(childObjectUrn);
                    }
                }


                return(result);
            }

            return(result);
        }
Exemple #4
0
        protected internal override DBObject InternalResolveChildObject(DBObjectUrn childObjectUrn)
        {
            DBObject result = null;

            if (Util.StringEqual(childObjectUrn[ItemType], this.Name, true))
            {
                result = this;
            }

            return(result);
        }
Exemple #5
0
        protected internal override DBObject InternalResolveChildObject(DBObjectUrn childObjectUrn)
        {
            DBObject result = null;

            if (Util.StringEqual(childObjectUrn[DbItemType.Schema], this.Name, true))
            {
                result = this;

                string tableName = childObjectUrn[DbItemType.Table];
                if (!string.IsNullOrEmpty(tableName))
                {
                    Table tableObj = this.Tables.SingleOrDefault(delegate(Table table)
                    {
                        bool tableNameEquals = Util.StringEqual(table.Name, tableName, true);
                        if (!string.IsNullOrEmpty(childObjectUrn.TableSchema))
                        {
                            return(tableNameEquals && Util.StringEqual(this.Name, childObjectUrn.TableSchema, true));
                        }

                        return(tableNameEquals);
                    });

                    if (tableObj != null)
                    {
                        result = tableObj.InternalResolveChildObject(childObjectUrn);
                    }
                }

                string viewName = childObjectUrn[DbItemType.View];
                if (!string.IsNullOrEmpty(viewName))
                {
                    View viewObj = this.Views.SingleOrDefault(delegate(View view)
                    {
                        bool viewNameEquals = Util.StringEqual(view.Name, viewName, true);
                        if (!string.IsNullOrEmpty(childObjectUrn.TableSchema))
                        {
                            return(viewNameEquals && Util.StringEqual(this.Name, childObjectUrn.TableSchema, true));
                        }

                        return(viewNameEquals);
                    });

                    if (viewObj != null)
                    {
                        result = viewObj.InternalResolveChildObject(childObjectUrn);
                    }
                }
            }

            return(result);
        }
Exemple #6
0
        public static DBObjectUrn Parse(string urn)
        {
            string[]    items  = urn.Split('/');
            DBObjectUrn result = new DBObjectUrn();

            foreach (string item in items)
            {
                if (string.IsNullOrEmpty(item))
                {
                    continue;
                }
                string[]   subitems1 = item.Split('[');
                DbItemType itemType  = (DbItemType)Enum.Parse(enumType, subitems1[0], true);

                string namePart = subitems1[1];
                int    startIdx = namePart.IndexOf("'");
                int    endIdx   = namePart.IndexOf("'", startIdx + 1);

                string itemName = namePart.Substring(startIdx + 1, endIdx - startIdx - 1);

                if (itemType == DbItemType.Table /*|| itemType == View*/)
                {
                    if (namePart.ToLower().Contains("@schema"))
                    {
                        ;
                    }
                    {
                        startIdx = namePart.IndexOf("'", endIdx + 1);
                        if (startIdx > -1)
                        {
                            endIdx = namePart.IndexOf("'", startIdx + 1);

                            if (endIdx > -1)
                            {
                                result.TableSchema = namePart.Substring(startIdx + 1, endIdx - startIdx - 1);
                            }
                        }
                    }
                }

                result.parts[itemType] = itemName;
            }

            return(result);
        }
Exemple #7
0
        protected internal override DBObject InternalResolveChildObject(DBObjectUrn childObjectUrn)
        {
            DBObject result = null;

            if (Util.StringEqual(childObjectUrn[DbItemType.Server], this.Name, true))
            {
                result = this;

                string dbName = childObjectUrn[DbItemType.Database];
                if (!string.IsNullOrEmpty(dbName))
                {
                    Database databaseObj = this.Databases.SingleOrDefault(database => Util.StringEqual(database.Name, dbName, true));
                    if (databaseObj != null)
                    {
                        result = databaseObj.InternalResolveChildObject(childObjectUrn);
                    }
                }
            }

            return(result);
        }
Exemple #8
0
        protected internal override DBObject InternalResolveChildObject(DBObjectUrn childObjectUrn)
        {
            DBObject result = base.InternalResolveChildObject(childObjectUrn);

            if (result != null)
            {
                result = this;

                string indexedColumnName = childObjectUrn[DbItemType.IndexedColumn];
                if (!string.IsNullOrEmpty(indexedColumnName))
                {
                    IndexedColumn indexedColumnObj = this.Columns.SingleOrDefault(column => Util.StringEqual(column.Name, indexedColumnName, true));
                    if (indexedColumnObj != null)
                    {
                        result = indexedColumnObj.InternalResolveChildObject(childObjectUrn);
                    }
                }

                return(result);
            }

            return(result);
        }
Exemple #9
0
        protected internal override DBObject InternalResolveChildObject(DBObjectUrn childObjectUrn)
        {
            DBObject result = base.InternalResolveChildObject(childObjectUrn);

            if (result != null)
            {
                result = this;

                string foreignKeyColumnName = childObjectUrn[DbItemType.ForeignKeyColumn];
                if (!string.IsNullOrEmpty(foreignKeyColumnName))
                {
                    ForeignKeyColumn foreignKeyColumnObj = this.ForeignKeyColumns.SingleOrDefault(item => Util.StringEqual(item.Name, foreignKeyColumnName, true));
                    if (foreignKeyColumnObj != null)
                    {
                        result = foreignKeyColumnObj.InternalResolveChildObject(childObjectUrn);
                    }
                }

                return(result);
            }

            return(result);
        }
Exemple #10
0
 protected internal abstract DBObject InternalResolveChildObject(DBObjectUrn childObjectUrn);
Exemple #11
0
        public DBObject ResolveChildObject(string childObjectUrn)
        {
            DBObjectUrn dbObjectUrn = DBObjectUrn.Parse(childObjectUrn);

            return(InternalResolveChildObject(dbObjectUrn));
        }