Пример #1
0
 public override void Visit(CastExpression expression)
 {
     _Query.Append(String.Concat("CAST("));
     expression.Expression.Accept(this);
     _Query.Append(" As ");
     _Query.Append(TypeName(expression.DbType, 0));
     _Query.Append(" ) ");
 }
Пример #2
0
        public override void Visit(CastExpression expression)
        {
            string function;
            switch (expression.DbType)
            {
                case DbType.Boolean:
                    function = "CBool";
                    break;
                case DbType.Byte:
                    function = "CByte";
                    break;
                case DbType.Date:
                case DbType.DateTime:
                    function = "CDate";
                    break;
                case DbType.Double:
                    function = "CDbl";
                    break;
                case DbType.Int32:
                    function = "CInt";
                    break;
                case DbType.Int64:
                    function = "CLng";
                    break;
                case DbType.Single:
                    function = "CSng";
                    break;
                case DbType.AnsiString:
                case DbType.AnsiStringFixedLength:
                case DbType.String:
                case DbType.StringFixedLength:
                    function = "CStr";
                    break;
                default:
                    throw new NotImplementedException(
                        "Cast to type " + expression.DbType + "is not implemented");
            }

            _Query.Append(function);
            _Query.Append("(");
            expression.Expression.Accept(this);
            _Query.Append(")");
        }
Пример #3
0
		public virtual void Visit(CastExpression expression)
		{
			string typeName = ConvertDbTypeToString(expression.DbType, expression.Size, expression.Precision, expression.Scale);
			_Query.Append(CONVERT).Append(OPENBRACE).Append(typeName).Append(COMMA);
			expression.Expression.Accept(this);
			_Query.Append(CLOSEBRACE);
		}