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); }
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); }