Пример #1
0
        internal static DBOrderSet OrderBy(string field, Order order)
        {
            DBField fld = DBField.Field(field);

            return(OrderBy(fld, order));
        }
Пример #2
0
 /// <summary>
 /// Adds a column to the  index with the ordering specified
 /// </summary>
 /// <param name="column"></param>
 /// <param name="order"></param>
 /// <returns></returns>
 public DBCreateIndexQuery Columns(string column, Order order)
 {
     this.ColumnOrders.Add(DBOrder.OrderBy(order, DBField.Field(column)));
     return(this);
 }
Пример #3
0
        /// <summary>
        /// Creates the first where clause by using the specified comparison between the specified owner.table.field and the clause
        /// </summary>
        /// <param name="fieldOwner">The schema owner of the table</param>
        /// <param name="fieldTable">The table the field belongs to</param>
        /// <param name="fieldName">The field to compare against</param>
        /// <param name="op">The comparison operator</param>
        /// <param name="value">The value clause</param>
        /// <returns>Itself so further statements can be combined</returns>
        public DBDeleteQuery WhereField(string fieldOwner, string fieldTable, string fieldName, Compare op, DBClause value)
        {
            DBField fld = DBField.Field(fieldOwner, fieldTable, fieldName);

            return(Where(fld, op, value));
        }
Пример #4
0
        protected virtual DBClause DoRead(string element, XmlReader reader, XmlReaderContext context)
        {
            DBClause c = null;

            switch (element)
            {
            case (XmlHelper.Select):
                c = DBSelectQuery.Select();
                break;

            case (XmlHelper.Delete):
                c = DBDeleteQuery.Delete();
                break;

            case (XmlHelper.Update):
                c = DBUpdateQuery.Update();
                break;

            case (XmlHelper.Insert):
                c = DBInsertQuery.InsertInto();
                break;

            case (XmlHelper.Script):
                c = DBQuery.Script();
                break;

            case (XmlHelper.Use):
                c = DBUseQuery.Use();
                break;

            case (XmlHelper.Table):
                c = DBTable.Table();
                break;

            case (XmlHelper.Fields):
                c = DBSelectSet.Select();
                break;

            case (XmlHelper.AField):
                c = DBField.Field();
                break;

            case (XmlHelper.AllFields):
                c = DBField.AllFields();
                break;

            case (XmlHelper.From):
                c = DBTableSet.From();
                break;

            case (XmlHelper.Where):
                c = DBFilterSet.Where();
                break;

            case (XmlHelper.Group):
                c = DBGroupBySet.GroupBy();
                break;

            case (XmlHelper.Order):
                c = DBOrderSet.OrderBy();
                break;

            case (XmlHelper.Assignments):
                c = DBAssignSet.Assign();
                break;

            case (XmlHelper.Values):
                c = DBValueSet.Values();
                break;

            case (XmlHelper.Join):
                c = DBJoin.Join();
                break;

            case (XmlHelper.Function):
                c = DBFunction.Function();
                break;

            case (XmlHelper.Constant):
                c = DBConst.Null();
                break;

            case (XmlHelper.Top):
                c = DBTop.Top();
                break;

            case (XmlHelper.UnaryOp):
                c = DBComparison.Not();
                break;

            case (XmlHelper.Compare):
                c = DBComparison.Compare();
                break;

            case (XmlHelper.Between):
                c = DBComparison.Between();
                break;

            case (XmlHelper.Parameter):
                //parameter is a special case.
                //we add them to akeyed colection if they are not already registered
                //then at the end we set the values at the end
                string  name = reader.GetAttribute(XmlHelper.Name);
                DBParam aparam;
                if (context.Parameters.TryGetParameter(name, out aparam))
                {
                    c = aparam;
                }
                else
                {
                    aparam      = DBParam.Param();
                    aparam.Name = name;
                    context.Parameters.Add(aparam);
                    c = aparam;
                }
                break;

            case (XmlHelper.OrderBy):
                c = DBOrder.OrderBy();
                break;

            case (XmlHelper.Calculation):
                c = DBCalc.Calculate();
                break;

            case (XmlHelper.Aggregate):
                c = DBAggregate.Aggregate();
                break;

            case (XmlHelper.ValueGroup):
                c = DBValueGroup.Empty();
                break;

            case (XmlHelper.BooleanOperator):
                c = DBBooleanOp.Compare();
                break;

            case (XmlHelper.Assign):
                c = DBAssign.Assign();
                break;

            case (XmlHelper.InnerSelect):
                c = DBSubQuery.SubSelect();
                break;

            case (XmlHelper.Multiple):
                c = DBMultiComparisonRef.Many();
                break;

            case (XmlHelper.QueryOptionSet):
                c = new DBQueryHintOptionSet();
                break;

            case (XmlHelper.QueryOption):
                c = DBQueryHintOption.QueryOption();
                break;

            case (XmlHelper.CreateSproc):
                c = DBCreateProcedureQuery.CreateProcedure();
                break;

            case (XmlHelper.Declare):
                c = DBDeclaration.Declare();
                break;

            case (XmlHelper.CreateTable):
                c = DBCreateTableQuery.Table();
                break;

            case (XmlHelper.ColumnDefinition):
                c = DBColumn.Column();
                break;

            case (XmlHelper.PrimaryKey):
                c = DBPrimaryKey.PrimaryKey();
                break;

            case (XmlHelper.ForeignKey):
                c = DBForeignKey.ForeignKey();
                break;

            case (XmlHelper.CreateIndex):
                c = DBCreateIndexQuery.Index();
                break;

            case (XmlHelper.CreateView):
                c = DBCreateViewQuery.CreateView();
                break;

            case (XmlHelper.CreateSequence):
                c = DBCreateSequenceQuery.Sequence();
                break;

            case (XmlHelper.DropTable):
                c = DBDropTableQuery.DropTable();
                break;

            case (XmlHelper.DropIndex):
                c = DBDropIndexQuery.DropIndex();
                break;

            case (XmlHelper.DropView):
                c = DBDropViewQuery.DropView();
                break;

            case (XmlHelper.DropSproc):
                c = DBDropProcedureQuery.DropProcedure();
                break;

            case (XmlHelper.DropSequence):
                c = DBDropSequenceQuery.DropSequence();
                break;

            default:
                throw XmlHelper.CreateException("The XML data could not be deserialized because the element {1} was not recognised. {0}", reader, null, element);
            }

            if (c != null)
            {
                c.ReadXml(reader, context);
            }

            return(c);
        }
Пример #5
0
 /// <summary>
 /// Creates a new Count('field') aggregation
 /// </summary>
 /// <param name="field"></param>
 /// <returns></returns>
 public static DBAggregate Count(string field)
 {
     return(Aggregate(AggregateFunction.Count, DBField.Field(field)));
 }
Пример #6
0
        /// <summary>
        /// Creates the first where clause by using the specified comparison between the specified field and the clause
        /// </summary>
        /// <param name="field">The field to compare against</param>
        /// <param name="op">The comparison operator</param>
        /// <param name="value">The value clause</param>
        /// <returns>Itself so further statements can be combined</returns>
        public DBDeleteQuery WhereField(string field, Compare op, DBClause value)
        {
            DBField fld = DBField.Field(field);

            return(Where(fld, op, value));
        }
Пример #7
0
 /// <summary>
 /// Creates a new Count(*) aggregation
 /// </summary>
 /// <returns></returns>
 public static DBAggregate CountAll()
 {
     return(Aggregate(AggregateFunction.Count, DBField.AllFields()));
 }
Пример #8
0
        internal static DBGroupBySet GroupBy(string owner, string table, string field)
        {
            DBField fld = DBField.Field(owner, table, field);

            return(GroupBy(fld));
        }
Пример #9
0
        internal static DBGroupBySet GroupBy(string field)
        {
            DBField fld = DBField.Field(field);

            return(GroupBy(fld));
        }
Пример #10
0
 /// <summary>
 /// Creates a new IsNull function reference to be executed on the database server - ISNULL(schema.table.field, otherwise)
 /// </summary>
 /// <param name="owner"></param>
 /// <param name="table"></param>
 /// <param name="field"></param>
 /// <param name="otherwise"></param>
 /// <returns></returns>
 public static DBFunction IsNull(string owner, string table, string field, DBClause otherwise)
 {
     return(IsNull(DBField.Field(owner, table, field), otherwise));
 }
Пример #11
0
        //
        // static factory methods
        //

        #region public static DBFunction IsNull(string field, DBClause otherwise) + 3 overloads

        /// <summary>
        /// Creates a new IsNull function reference to be executed on the database server - ISNULL(field, otherwise)
        /// </summary>
        /// <param name="field"></param>
        /// <param name="otherwise"></param>
        /// <returns></returns>
        public static DBFunction IsNull(string field, DBClause otherwise)
        {
            return(IsNull(DBField.Field(field), otherwise));
        }