public override void Prepare() { base.Prepare(); if (!(Operand1.GetResultType() == SimpleTypes.String && Operand2.GetResultType() == SimpleTypes.Integer)) { TypesException(); } SetResultType(SimpleTypes.String); GetStrResultOut = CalcAsStr; }
public override void Prepare() { base.Prepare(); if (!(Operand1.GetResultType() == SimpleTypes.String && Operand2.GetResultType() == SimpleTypes.String)) { TypesException(); } //if (!Operand2.OnlyOnline()) OperandOnlyConstException(2); SetResultType(SimpleTypes.Boolean); GetBoolResultOut = CalcAsBool; }
public override void Prepare() { base.Prepare(); SimpleTypes t1 = Operand1.GetResultType(); SimpleTypes t2 = Operand2.GetResultType(); //public enum ColumnSimpleTypes { Integer = 1, Float = 2, String = 3, Geometry = 4, Date = 5, DateTime = 6, Time = 7, Boolean = 8 } if (t1 == SimpleTypes.String && t2 == SimpleTypes.String) { GetStrResultOut = CalcAsStr; SetResultType(SimpleTypes.String); return; } if (t1 == SimpleTypes.Integer && t2 == SimpleTypes.Integer) { GetIntResultOut = CalcAsInt; SetResultType(SimpleTypes.Integer); return; } if ((t1 == SimpleTypes.Integer || t1 == SimpleTypes.Float) && (t2 == SimpleTypes.Integer || t2 == SimpleTypes.Float)) { GetFloatResultOut = CalcAsFloat; SetResultType(SimpleTypes.Float); return; } if ((t1 == SimpleTypes.DateTime || t1 == SimpleTypes.Date) && t2 == SimpleTypes.Time) { GetDateTimeResultOut = CalcAsDateTimeAndTime1; SetResultType(SimpleTypes.DateTime); return; } if ((t2 == SimpleTypes.DateTime || t2 == SimpleTypes.Date) && t1 == SimpleTypes.Time) { GetDateTimeResultOut = CalcAsDateTimeAndTime2; SetResultType(SimpleTypes.DateTime); return; } if (t2 == SimpleTypes.Time && t1 == SimpleTypes.Time) { GetTimeResultOut = CalcAsTimeAndTime; SetResultType(SimpleTypes.Time); return; } /*if (t2 == ColumnSimpleTypes.Geometry && t1 == ColumnSimpleTypes.Geometry) * { * GetGeomResultOut = CalcAsGeom; * SetResultType(ColumnSimpleTypes.Geometry); * return; * }*/ TypesException(); }
public override void Prepare() { base.Prepare(); if (Operand1.GetResultType() != SimpleTypes.Boolean) { this.TypesException(); } if (Operand2.GetResultType() != SimpleTypes.Boolean) { this.TypesException(); } GetBoolResultOut = AsBool; SetResultType(SimpleTypes.Boolean); }
public override void Prepare() { base.Prepare(); if (!(Operand1.GetResultType() == SimpleTypes.String)) { TypesException(); //substring } if (!(Operand2.GetResultType() == SimpleTypes.String)) { TypesException(); //string } SetResultType(SimpleTypes.Integer); GetIntResultOut = CalcRes; }
public override string ToSql(ExpressionSqlBuilder builder) { if (builder.DbType == DriverType.SqlServer) { string op = "+"; SimpleTypes t1 = Operand1.GetResultType(); SimpleTypes t2 = Operand2.GetResultType(); if (t2 == SimpleTypes.Time && t1 == SimpleTypes.Time) { return("CONVERT(time, CONVERT(datetime, " + Operand1.ToSql(builder) + ")" + op + "CONVERT(datetime, " + Operand2.ToSql(builder) + "))"); } if (t1 == SimpleTypes.Date && t2 == SimpleTypes.Time) { return("(CONVERT(datetime, " + Operand1.ToSql(builder) + ")" + op + Operand2.ToSql(builder) + ")"); } if (t2 == SimpleTypes.Date && t1 == SimpleTypes.Time) { return("(CONVERT(datetime, " + Operand2.ToSql(builder) + ")" + op + Operand1.ToSql(builder) + ")"); } if (t1 == SimpleTypes.Geometry && t2 == SimpleTypes.Geometry) { if (op == "+") { return("(" + Operand2.ToSql(builder) + ".STUnion(" + Operand1.ToSql(builder) + "))"); } if (op == "-") { return("(" + Operand2.ToSql(builder) + ".STDifference(" + Operand1.ToSql(builder) + "))"); } } return("(" + Operand1.ToSql(builder) + op + Operand2.ToSql(builder) + ")"); } if (builder.DbType == DriverType.PostgreSQL) { string op = "+"; SimpleTypes t1 = Operand1.GetResultType(); SimpleTypes t2 = Operand2.GetResultType(); if (t1 == SimpleTypes.String || t2 == SimpleTypes.String) { op = "||"; } if (t2 == SimpleTypes.Time && t1 == SimpleTypes.Time) { return("(" + Operand1.ToSql(builder) + op + "CAST(" + Operand2.ToSql(builder) + " as interval))"); } return("(" + Operand1.ToSql(builder) + op + Operand2.ToSql(builder) + ")"); } return(ToSqlException()); }
public override void Prepare() { base.Prepare(); SimpleTypes st = SimpleTypes.DateTime; if (Operand1.GetResultType() == SimpleTypes.DateTime) { st = SimpleTypes.DateTime; GetDateTimeResultOut = GetResultDate; } if (Operand1.GetResultType() == SimpleTypes.Date) { st = SimpleTypes.Date; GetDateTimeResultOut = GetResultDate; } if (Operand1.GetResultType() == SimpleTypes.Time) { st = SimpleTypes.Time; GetTimeResultOut = GetResultTime; } SetResultType(st); }
public override void Prepare() { base.Prepare(); SimpleTypes t1 = Operand1.GetResultType(); SimpleTypes t2 = Operand2.GetResultType(); //public enum ColumnSimpleTypes { Integer = 1, Float = 2, String = 3, Geometry = 4, Date = 5, DateTime = 6, Time = 7, Boolean = 8 } if (t1 == SimpleTypes.Integer && t2 == SimpleTypes.Integer) { GetIntResultOut = CalcAsInt; SetResultType(SimpleTypes.Integer); return; } if ((t1 == SimpleTypes.Integer || t1 == SimpleTypes.Float) && (t2 == SimpleTypes.Integer || t2 == SimpleTypes.Float)) { GetFloatResultOut = CalcAsFloat; SetResultType(SimpleTypes.Float); return; } TypesException(); }
protected bool DoPrepare() { SimpleTypes t1 = Operand1.GetResultType(); SimpleTypes t2 = Operand2.GetResultType(); //SortType(ref t1, ref t2); SetResultType(SimpleTypes.Boolean); //если один операнд строка, а второй не строка. Проверка для констант if ((t1 == SimpleTypes.String && t2 != SimpleTypes.String) || (t2 == SimpleTypes.String && t1 != SimpleTypes.String)) { //находим не строковый элемент Expression notStrOper = Operand1; Expression StrOper = Operand2; if (StrOper.GetResultType() != SimpleTypes.String) { notStrOper = Operand2; StrOper = Operand1; } SimpleTypes notStr = notStrOper.GetResultType(); if (StrOper is ConstExpr) { switch (notStr) { case SimpleTypes.Integer: GetBoolResultOut = CompareAsInt; (StrOper as ConstExpr).PrepareFor(SimpleTypes.Integer); return(true); case SimpleTypes.Float: GetBoolResultOut = CompareAsFloat; (StrOper as ConstExpr).PrepareFor(SimpleTypes.Float); return(true); case SimpleTypes.Date: case SimpleTypes.DateTime: GetBoolResultOut = CompareAsDateTime; (StrOper as ConstExpr).PrepareFor(SimpleTypes.DateTime); return(true); case SimpleTypes.Time: GetBoolResultOut = CompareAsTime; (StrOper as ConstExpr).PrepareFor(SimpleTypes.Time); return(true); } } } if (t1 == SimpleTypes.String && t2 == SimpleTypes.String) { GetBoolResultOut = CompareAsStr; return(true); } if (t1 == SimpleTypes.Integer && t2 == SimpleTypes.Integer) { GetBoolResultOut = CompareAsInt; return(true); } if ((t1 == SimpleTypes.Integer || t1 == SimpleTypes.Float) && (t2 == SimpleTypes.Integer || t2 == SimpleTypes.Float)) { GetBoolResultOut = CompareAsFloat; return(true); } if ((t1 == SimpleTypes.Date || t1 == SimpleTypes.DateTime) && (t2 == SimpleTypes.Date || t2 == SimpleTypes.DateTime)) { GetBoolResultOut = CompareAsDateTime; return(true); } if (t1 == SimpleTypes.Time && t2 == SimpleTypes.Time) { GetBoolResultOut = CompareAsTime; return(true); } return(false); }