Пример #1
0
        private DmlfConditionBase DateTimeIntervalCondition(DateTime begin, DateTime end)
        {
            var and = new DmlfAndCondition();

            and.Conditions.Add(new DmlfRelationCondition
            {
                LeftExpr  = _columnValue,
                Relation  = ">=",
                RightExpr = new DmlfLiteralExpression {
                    Value = StringTool.DateTimeToIsoStringExact(begin)
                }
            });
            and.Conditions.Add(new DmlfRelationCondition
            {
                LeftExpr  = _columnValue,
                Relation  = "<",
                RightExpr = new DmlfLiteralExpression {
                    Value = StringTool.DateTimeToIsoStringExact(end)
                }
            });
            return(and);
        }
Пример #2
0
 public override void SetDateTime(DateTime value)
 {
     m_text = "'" + StringTool.DateTimeToIsoStringExact(value) + "'";
 }
Пример #3
0
        public static void GetValueAsSqlLiteral(ICdlValueReader rec, out string sqldata)
        {
            var type = rec.GetFieldType();

            if (type == TypeStorage.Null)
            {
                sqldata = "null";
                return;
            }
            switch (type)
            {
            case TypeStorage.Boolean:
                sqldata = rec.GetBoolean() ? "1" : "0";
                break;

            case TypeStorage.Byte:
                sqldata = rec.GetByte().ToString(CultureInfo.InvariantCulture);
                break;

            case TypeStorage.Int16:
                sqldata = rec.GetInt16().ToString(CultureInfo.InvariantCulture);
                break;

            case TypeStorage.Int32:
                sqldata = rec.GetInt32().ToString(CultureInfo.InvariantCulture);
                break;

            case TypeStorage.Int64:
                sqldata = rec.GetInt64().ToString(CultureInfo.InvariantCulture);
                break;

            case TypeStorage.SByte:
                sqldata = rec.GetSByte().ToString(CultureInfo.InvariantCulture);
                break;

            case TypeStorage.UInt16:
                sqldata = rec.GetUInt16().ToString(CultureInfo.InvariantCulture);
                break;

            case TypeStorage.UInt32:
                sqldata = rec.GetUInt32().ToString(CultureInfo.InvariantCulture);
                break;

            case TypeStorage.UInt64:
                sqldata = rec.GetUInt64().ToString(CultureInfo.InvariantCulture);
                break;

            case TypeStorage.DateTime:
                sqldata = "'" + StringTool.DateTimeToIsoStringExact(rec.GetDateTime()) + "'";
                break;

            case TypeStorage.DateTimeEx:
                sqldata = "'" + rec.GetDateTimeEx().ToStringNormalized() + "'";
                break;

            case TypeStorage.DateEx:
                sqldata = "'" + rec.GetDateEx().ToStringNormalized() + "'";
                break;

            case TypeStorage.TimeEx:
                sqldata = "'" + rec.GetTimeEx().ToStringNormalized() + "'";
                break;

            case TypeStorage.Decimal:
                sqldata = rec.GetDecimal().ToString(CultureInfo.InvariantCulture);
                break;

            case TypeStorage.Float:
                sqldata = rec.GetFloat().ToString(CultureInfo.InvariantCulture);
                break;

            case TypeStorage.Double:
                sqldata = rec.GetDouble().ToString(CultureInfo.InvariantCulture);
                break;

            case TypeStorage.String:
                sqldata = "'" + rec.GetString().Replace("'", "''") + "'";
                break;

            case TypeStorage.Guid:
                sqldata = "'" + rec.GetGuid().ToString() + "'";
                break;

            case TypeStorage.ByteArray:
            {
                byte[] data = rec.GetByteArray();
                sqldata = "X'" + StringTool.EncodeHex(data) + "'";
            }
            break;

            //case TypeStorage.Array:
            //    {
            //        xtype = "array";
            //        xdata = CdlArray.ToString(rec.GetArray());
            //    }
            //    break;
            default:
                throw new Exception("DBSH-00166 Unsupported field type:" + type.ToString());
            }
        }