UnformatSqlName() static private method

Get the name of a SqlObject without owner and schema, and unformat the name
[dbo]..[foo] returns foo
static private UnformatSqlName ( string name ) : string
name string The full name to clean up
return string
コード例 #1
0
        public SqlName Append(string objectName)
        {
            if (Table != Object)
            {
                throw new InvalidOperationException("Cannot get a child of an object that is not a table");
            }

            SqlName child = (SqlName)MemberwiseClone();

            child.Object = SqlParser.UnformatSqlName(objectName);

            return(child);
        }
コード例 #2
0
        public SqlName(string fullName, int expectedParts)
        {
            Original = fullName;

            var split = SplitSqlName(fullName);

            if (split.Length < expectedParts)
            {
                fullName = "[dbo]." + fullName;
                split    = SplitSqlName(fullName);
            }

            // in some special cases (autoproc, permissions), we just need the original
            if (split.Length > expectedParts)
            {
                return;
            }

            if (split.Length == 1)
            {
                Table  = split[0];
                Object = split[0];
            }
            else if (split.Length == 2)
            {
                Schema = split[0];
                Table  = split[1];
                Object = split[1];
            }
            else if (split.Length == 3)
            {
                Schema = split[0];
                Table  = split[1];
                Object = split[2];
            }

            if (split.Length > 1 && String.IsNullOrWhiteSpace(Schema))
            {
                Schema = "dbo";
            }

            Schema = SqlParser.UnformatSqlName(Schema);
            Table  = SqlParser.UnformatSqlName(Table);
            Object = SqlParser.UnformatSqlName(Object);
        }