Ejemplo n.º 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;
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 5
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));
			}
		}
Ejemplo n.º 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));
     }
 }
Ejemplo n.º 7
0
		public SelectColumn(Enum columnName, FromTerm table)
			: this(columnName.ToString(), table, null) {}
Ejemplo n.º 8
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) {}
Ejemplo n.º 9
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;
		}
Ejemplo n.º 10
0
		public static SqlExpression Field(Enum fieldName, FromTerm table)
		{
			return Field(fieldName.ToString(), table);
		}
Ejemplo n.º 11
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;
		}
Ejemplo n.º 12
0
 public OrderByTerm(Enum field, FromTerm table, OrderByDirection dir) : this(field.ToString(), table, dir)
 {
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Creates an ORDER BY term
 /// </summary>
 public OrderByTerm()
 {
     field     = null;
     table     = null;
     direction = OrderByDirection.Ascending;
 }
Ejemplo n.º 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;
		}
Ejemplo n.º 15
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) {}
Ejemplo n.º 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;
		}
Ejemplo n.º 17
0
 public static SqlExpression Field(Enum firstPart, Enum secondPart, FromTerm table)
 {
     return(Field(firstPart.ToString() + "." + secondPart.ToString(), table));
 }
Ejemplo n.º 18
0
 public static SqlExpression Field(Enum fieldName, FromTerm table)
 {
     return(Field(fieldName.ToString(), table));
 }
Ejemplo n.º 19
0
		public static SqlExpression Field(Enum firstPart, Enum secondPart, FromTerm table)
		{
			return Field(firstPart.ToString() + "." + secondPart.ToString(), table);
		}
Ejemplo n.º 20
0
        /// <summary>
        /// Creates a new SelectQuery
        /// </summary>
        public SelectQuery(Enum entity)
        {
            FromTerm term = FromTerm.Table(entity.ToString(), entity.ToString().ToLower());

            FromClause.BaseTable = term;
        }
Ejemplo n.º 21
0
		public SelectColumn(Enum columnName, FromTerm table, SqlAggregationFunction function) : this(columnName.ToString(), table, function) {}
Ejemplo n.º 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)
 {
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 24
0
 public SelectColumn(Enum columnName, FromTerm table)
     : this(columnName.ToString(), table, null)
 {
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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)
 {
 }
Ejemplo n.º 27
0
		/// <summary>
		/// Creates an ORDER BY term 
		/// </summary>
		public OrderByTerm()
		{
			field = null;
			table = null;
			direction = OrderByDirection.Ascending;
		}
Ejemplo n.º 28
0
 public SelectColumn(Enum columnName, FromTerm table, SqlAggregationFunction function) : this(columnName.ToString(), table, function)
 {
 }
Ejemplo n.º 29
0
		public OrderByTerm(Enum field, FromTerm table, OrderByDirection dir) : this(field.ToString(), table, dir) {}
Ejemplo n.º 30
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;
		}