Beispiel #1
0
        public SelectQuery(Type t)
        {
            string[] parts      = t.ToString().Split(new[] { '.' });
            string   entityName = parts[parts.Length - 1];
            FromTerm term       = FromTerm.Table(entityName, entityName.ToLower());

            FromClause.BaseTable = term;
        }
Beispiel #2
0
        /// <summary>
        /// Creates a SqlExpression which represents a field in a database table.
        /// </summary>
        /// <param name="fieldName">Name of a field</param>
        /// <param name="table">The table this field belongs to</param>
        /// <returns></returns>
        public static SqlExpression Field(string fieldName, FromTerm table)
        {
            SqlExpression expr = new SqlExpression();

            expr.val   = fieldName;
            expr.table = table;
            expr.type  = SqlExpressionType.Field;
            return(expr);
        }
Beispiel #3
0
        /// <summary>
        /// Creates a FromTerm which represents a sub-query.
        /// </summary>
        /// <param name="query">A SelectQuery instance representing the sub query</param>
        /// <param name="alias">term alias</param>
        /// <returns>A FromTerm which represents a sub-query.</returns>
        public static FromTerm SubQuery(SelectQuery query, string alias)
        {
            FromTerm term = new FromTerm();

            term.expr  = query;
            term.alias = alias;
            term.type  = FromTermType.SubQueryObj;
            return(term);
        }
Beispiel #4
0
        /// <summary>
        /// Creates a FromTerm which represents a database table or view.
        /// </summary>
        /// <param name="tableName">Name of the table or view</param>
        /// <param name="alias">Alias of the FromTerm</param>
        /// <param name="ns1">First table namespace</param>
        /// <param name="ns2">Second table namespace</param>
        /// <returns>A FromTerm which represents a database table or view</returns>
        /// <remarks>Use the <paramref name="ns1"/> parameter to set table database and <paramref name="ns2"/> to set table owner.</remarks>
        public static FromTerm Table(string tableName, string alias, string ns1, string ns2)
        {
            FromTerm term = new FromTerm();

            term.expr  = tableName;
            term.alias = alias;
            term.type  = FromTermType.Table;
            term.ns1   = ns1;
            term.ns2   = ns2;
            return(term);
        }
		public SelectColumn(string columnName, FromTerm table, SqlAggregationFunction function)
		{
			if (function == SqlAggregationFunction.None)
			{
				expr = SqlExpression.Field(columnName, table);
			}
			else
			{
				expr = SqlExpression.Function(function, SqlExpression.Field(columnName, table));
			}
		}
Beispiel #6
0
 public SelectColumn(string columnName, FromTerm table, SqlAggregationFunction function)
 {
     if (function == SqlAggregationFunction.None)
     {
         expr = SqlExpression.Field(columnName, table);
     }
     else
     {
         expr = SqlExpression.Function(function, SqlExpression.Field(columnName, table));
     }
 }
		public SelectColumn(Enum columnName, FromTerm table)
			: this(columnName.ToString(), table, null) {}
		/// <summary>
		/// Creates a SelectColumn with a column name, table, no column alias and no function
		/// </summary>
		/// <param name="columnName">Name of a column</param>
		/// <param name="table">The table this field belongs to</param>
		public SelectColumn(string columnName, FromTerm table) : this(columnName, table, null) {}
		/// <summary>
		/// Creates a GROUP BY term with field name and table alias
		/// </summary>
		/// <param name="field">Name of a field to group by</param>
		/// <param name="table">The table this field belongs to</param>
		public GroupByTerm(string field, FromTerm table)
		{
			this.field = field;
			this.table = table;
		}
		public static SqlExpression Field(Enum fieldName, FromTerm table)
		{
			return Field(fieldName.ToString(), table);
		}
		/// <summary>
		/// Creates an ORDER BY term with field name and table alias
		/// </summary>
		/// <param name="field">Name of a field to order by</param>
		/// <param name="table">The table this field belongs to</param>
		/// <param name="dir">Order by direction</param>
		public OrderByTerm(string field, FromTerm table, OrderByDirection dir)
		{
			this.field = field;
			this.table = table;
			direction = dir;
		}
Beispiel #12
0
 public OrderByTerm(Enum field, FromTerm table, OrderByDirection dir) : this(field.ToString(), table, dir)
 {
 }
Beispiel #13
0
 /// <summary>
 /// Creates an ORDER BY term
 /// </summary>
 public OrderByTerm()
 {
     field     = null;
     table     = null;
     direction = OrderByDirection.Ascending;
 }
Beispiel #14
0
		/// <summary>
		/// Creates a FromTerm which represents a sub-query.
		/// </summary>
		/// <param name="query">A SelectQuery instance representing the sub query</param>
		/// <param name="alias">term alias</param>
		/// <returns>A FromTerm which represents a sub-query.</returns>
		public static FromTerm SubQuery(SelectQuery query, string alias)
		{
			FromTerm term = new FromTerm();
			term.expr = query;
			term.alias = alias;
			term.type = FromTermType.SubQueryObj;
			return term;
		}
		/// <summary>
		/// Creates a SelectColumn with a column name, table and column alias
		/// </summary>
		/// <param name="columnName">Name of a column</param>
		/// <param name="table">The table this field belongs to</param>
		/// <param name="columnAlias">Alias of the column</param>
		public SelectColumn(string columnName, FromTerm table, string columnAlias) : this(columnName, table, columnAlias, SqlAggregationFunction.None) {}
Beispiel #16
0
		/// <summary>
		/// Creates a FromTerm which represents a database table or view.
		/// </summary>
		/// <param name="tableName">Name of the table or view</param>
		/// <param name="alias">Alias of the FromTerm</param>
		/// <param name="ns1">First table namespace</param>
		/// <param name="ns2">Second table namespace</param>
		/// <returns>A FromTerm which represents a database table or view</returns>
		/// <remarks>Use the <paramref name="ns1"/> parameter to set table database and <paramref name="ns2"/> to set table owner.</remarks>
		public static FromTerm Table(string tableName, string alias, string ns1, string ns2)
		{
			FromTerm term = new FromTerm();
			term.expr = tableName;
			term.alias = alias;
			term.type = FromTermType.Table;
			term.ns1 = ns1;
			term.ns2 = ns2;
			return term;
		}
Beispiel #17
0
 public static SqlExpression Field(Enum firstPart, Enum secondPart, FromTerm table)
 {
     return(Field(firstPart.ToString() + "." + secondPart.ToString(), table));
 }
Beispiel #18
0
 public static SqlExpression Field(Enum fieldName, FromTerm table)
 {
     return(Field(fieldName.ToString(), table));
 }
		public static SqlExpression Field(Enum firstPart, Enum secondPart, FromTerm table)
		{
			return Field(firstPart.ToString() + "." + secondPart.ToString(), table);
		}
Beispiel #20
0
        /// <summary>
        /// Creates a new SelectQuery
        /// </summary>
        public SelectQuery(Enum entity)
        {
            FromTerm term = FromTerm.Table(entity.ToString(), entity.ToString().ToLower());

            FromClause.BaseTable = term;
        }
		public SelectColumn(Enum columnName, FromTerm table, SqlAggregationFunction function) : this(columnName.ToString(), table, function) {}
Beispiel #22
0
 /// <summary>
 /// Creates a SelectColumn with a column name, table, no column alias and no function
 /// </summary>
 /// <param name="columnName">Name of a column</param>
 /// <param name="table">The table this field belongs to</param>
 public SelectColumn(string columnName, FromTerm table) : this(columnName, table, null)
 {
 }
Beispiel #23
0
 /// <summary>
 /// Creates a GROUP BY term with field name and table alias
 /// </summary>
 /// <param name="field">Name of a field to group by</param>
 /// <param name="table">The table this field belongs to</param>
 public GroupByTerm(string field, FromTerm table)
 {
     this.field = field;
     this.table = table;
 }
Beispiel #24
0
 public SelectColumn(Enum columnName, FromTerm table)
     : this(columnName.ToString(), table, null)
 {
 }
Beispiel #25
0
 /// <summary>
 /// Creates an ORDER BY term with field name and table alias
 /// </summary>
 /// <param name="field">Name of a field to order by</param>
 /// <param name="table">The table this field belongs to</param>
 /// <param name="dir">Order by direction</param>
 public OrderByTerm(string field, FromTerm table, OrderByDirection dir)
 {
     this.field = field;
     this.table = table;
     direction  = dir;
 }
Beispiel #26
0
 /// <summary>
 /// Creates a SelectColumn with a column name, table and column alias
 /// </summary>
 /// <param name="columnName">Name of a column</param>
 /// <param name="table">The table this field belongs to</param>
 /// <param name="columnAlias">Alias of the column</param>
 public SelectColumn(string columnName, FromTerm table, string columnAlias) : this(columnName, table, columnAlias, SqlAggregationFunction.None)
 {
 }
		/// <summary>
		/// Creates an ORDER BY term 
		/// </summary>
		public OrderByTerm()
		{
			field = null;
			table = null;
			direction = OrderByDirection.Ascending;
		}
Beispiel #28
0
 public SelectColumn(Enum columnName, FromTerm table, SqlAggregationFunction function) : this(columnName.ToString(), table, function)
 {
 }
		public OrderByTerm(Enum field, FromTerm table, OrderByDirection dir) : this(field.ToString(), table, dir) {}
		/// <summary>
		/// Creates a SqlExpression which represents a field in a database table.
		/// </summary>
		/// <param name="fieldName">Name of a field</param>
		/// <param name="table">The table this field belongs to</param>
		/// <returns></returns>
		public static SqlExpression Field(string fieldName, FromTerm table)
		{
			SqlExpression expr = new SqlExpression();
			expr.val = fieldName;
			expr.table = table;
			expr.type = SqlExpressionType.Field;
			return expr;
		}