public ReturningColumn(string name) { var f = ReturningColumn.Parse(name); _column = f._column; _alias = f._alias; }
public static ReturningColumn Parse(string sqlStatement) { var field = new ReturningColumn(); 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 == "*") { field._alias = null; } field._column = sqlStatement; return(field); }