public FromSourceTableOrView(string name)
        {
            var f = FromSourceTableOrView.Parse(name);

            _schema = f._schema;
            _name   = f._name;
            _alias  = f._alias;
        }
        public static FromSourceTableOrView Parse(string sqlStatement)
        {
            var field = new FromSourceTableOrView();

            if (sqlStatement == null)
            {
                throw new ArgumentNullException(nameof(sqlStatement));
            }

            sqlStatement = sqlStatement.ClearString();

            if (sqlStatement.EndsWith(" AS", StringComparison.OrdinalIgnoreCase))
            {
                sqlStatement = sqlStatement.Substring(0, sqlStatement.Length - 3);
            }
            var indexOfAs = sqlStatement.ToUpper().IndexOf(" AS ", StringComparison.OrdinalIgnoreCase);

            if (indexOfAs > 0)
            {
                field._alias = sqlStatement.Substring(indexOfAs + 4).ClearString();
                sqlStatement = sqlStatement.Substring(0, indexOfAs).ClearString();
            }

            if (sqlStatement.Contains("."))
            {
                var arr = sqlStatement.Split('.');
                field._schema = arr[0].ClearString();
                sqlStatement  = arr[1].ClearString();
            }

            if (sqlStatement == "*")
            {
                field._alias = null;
            }

            field._name = sqlStatement;

            return(field);
        }
Beispiel #3
0
        public From AddTableOrView(string schema, string name, string alias)
        {
            var t = new FromSourceTableOrView(schema, name, alias);

            return(AddTableOrView(t));
        }
Beispiel #4
0
        public From AddTableOrView(string name)
        {
            var t = new FromSourceTableOrView(name);

            return(AddTableOrView(t));
        }
Beispiel #5
0
 public From AddTableOrView(FromSourceTableOrView sourceTableOrView)
 {
     _fromSources.Add(sourceTableOrView);
     return(this);
 }