Esempio n. 1
0
        static IExecuteHandler GetHandler()
        {
            IExecuteHandler handler = new GetValue();
            Type            type    = typeof(T);

            if (type.IsValueType || type == typeof(String))
            {
                handler      = new GetValue();
                handler.Type = type;
            }
            else
            {
                if (type.GetInterface("System.Collections.Generic.IList`1") != null ||

                    type.Name == "IList`1")
                {
                    Type[] subtype = type.GetGenericArguments();
                    handler      = new GetObjects();
                    handler.Type = subtype[0];
                }
                else
                {
                    handler      = new GetObject();
                    handler.Type = type;
                }
            }

            return(handler);
        }
Esempio n. 2
0
        public object Execute(IConnectinContext cc, object value, HandlerValueType type)
        {
            string[] orderby  = DBContext.CurrentOrderBy;
            Region   curegion = DBContext.CurrentRegion;

            DBContext.CurrentRegion  = null;
            DBContext.CurrentOrderBy = null;
            switch (type)
            {
            case HandlerValueType.ValueType:
                return(DBContext.Load(Type, value, cc));

            case HandlerValueType.PROC:
                return(DBContext.ExecProcToObject(Type, cc, value));

            case HandlerValueType.SQL:
                return(((SQL)value).ListFirst(Type, cc));

            case HandlerValueType.EXPRESSION:
                return(((Expression)value).ListFirst(Type, cc, orderby));

            case HandlerValueType.String:
                string str = (string)value;
                if (GetValue.IsValueKey(str))
                {
                    return(DBContext.Load(Type, value, cc));
                }
                else
                {
                    if (GetValue.IsSelectSQL(str))
                    {
                        return(new SQL(str).ListFirst(Type, cc));
                    }
                    else
                    {
                        Expression exp = new Expression(str);
                        return(exp.ListFirst(Type, cc, orderby));
                    }
                }
            }
            return(null);
        }
Esempio n. 3
0
        public object Execute(IConnectinContext cc, object value, HandlerValueType type)
        {
            string[] orderby  = DBContext.CurrentOrderBy;
            Region   curegion = DBContext.CurrentRegion;

            DBContext.CurrentRegion  = null;
            DBContext.CurrentOrderBy = null;

            switch (type)
            {
            case HandlerValueType.String:
                string str = (string)value;
                if (GetValue.IsSelectSQL(str))
                {
                    return(new SQL(str).List(Type, cc, curegion));
                }
                else
                {
                    Expression exp = new Expression(str);
                    return(exp.List(Type, cc, curegion, orderby));
                }

            case HandlerValueType.SQL:
                return(((SQL)value).List(Type, cc, curegion));

                break;

            case HandlerValueType.PROC:
                return(cc.ListProc(Type, value));

            case HandlerValueType.EXPRESSION:
                return(((Expression)value).List(Type, cc, curegion, orderby));

            default:
                throw new PeanutException("object is not a [SQL,StoredProcedure,Expression]!");
            }
        }