Ejemplo n.º 1
0
        public override string ToString()
        {
            var sb = new StringBuilder();

            var parsedName = GlobalParser.GetParserString(this.key);


            if (this.withDatabase && !string.IsNullOrEmpty(this.DatabaseName))
            {
                sb.Append(this.withQuotes ? parsedName.QuotedDatabaseName : this.DatabaseName);
                sb.Append(this.withNormalized ? "_" : ".");
            }
            if (this.withSchema && !string.IsNullOrEmpty(this.SchemaName))
            {
                sb.Append(this.withQuotes ? parsedName.QuotedSchemaName : this.SchemaName);
                sb.Append(this.withNormalized ? "_" : ".");
            }

            var name = this.withQuotes ? parsedName.QuotedObjectName : this.ObjectName;

            name = this.withNormalized ? name.Replace(" ", "_").Replace(".", "_").Replace("-", "_") : name;
            sb.Append(name);

            // now we have the correct string, reset options for the next time we call the same instance
            withDatabase   = false;
            withSchema     = false;
            withQuotes     = false;
            withNormalized = false;

            return(sb.ToString());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Parse the input string and Get a non bracket object name :
        ///   "[Client] ==> Client "
        ///   "[dbo].[client] === > dbo client "
        ///   "dbo.client === > dbo client "
        ///   "Fabrikam.[dbo].[client] === > Fabrikam dbo client "
        /// </summary>
        private void ParseString(string input, string leftQuote = null, string rightQuote = null)
        {
            input    = input == null ? string.Empty : input.Trim();
            this.key = input;

            if (!string.IsNullOrEmpty(leftQuote) && !string.IsNullOrEmpty(rightQuote))
            {
                this.key = $"{leftQuote}^{rightQuote}^{input}";
            }
            else if (!string.IsNullOrEmpty(leftQuote))
            {
                this.key = $"{leftQuote}^{leftQuote}^{input}";
            }

            GlobalParser.GetParserString(this.key);
        }