public object GetValue(RequestScope request, ResultProperty mapping, ref IDataReader reader, object keys)
        {
            IMappedStatement mappedStatement = request.MappedStatement.SqlMap.GetMappedStatement(mapping.Select);

            reader = DataReaderTransformer.Transform(reader, request.Session.DataSource.DbProvider);
            return(mappedStatement.ExecuteQueryForObject(request.Session, keys));
        }
        public object GetValue(RequestScope request, ResultProperty mapping, ref IDataReader reader, object keys)
        {
            IMappedStatement mappedStatement = request.MappedStatement.SqlMap.GetMappedStatement(mapping.Select);

            reader = DataReaderTransformer.Transform(reader, request.Session.DataSource.DbProvider);
            Type[] genericArguments = mapping.MemberType.GetGenericArguments();
            typeof(IList <>).MakeGenericType(genericArguments);
            Type type2 = mapping.MemberType.GetGenericArguments()[0];

            MethodInfo[] methods = mappedStatement.GetType().GetMethods(BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance);
            MethodInfo   info    = null;

            foreach (MethodInfo info2 in methods)
            {
                if ((info2.IsGenericMethod && (info2.Name == "ExecuteQueryForList")) && (info2.GetParameters().Length == 2))
                {
                    info = info2;
                    break;
                }
            }
            MethodInfo info3 = info.MakeGenericMethod(new Type[] { type2 });

            object[] parameters = new object[] { request.Session, keys };
            return(info3.Invoke(mappedStatement, parameters));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets the value of an argument constructor.
        /// </summary>
        /// <param name="request">The current <see cref="RequestScope"/>.</param>
        /// <param name="mapping">The <see cref="ResultProperty"/> with the argument infos.</param>
        /// <param name="reader">The current <see cref="IDataReader"/>.</param>
        /// <param name="keys">The keys</param>
        /// <returns>The paremeter value.</returns>
        public object GetValue(RequestScope request, ResultProperty mapping,
                               ref IDataReader reader, object keys)
        {
            // Get the select statement
            IMappedStatement selectStatement = request.MappedStatement.ModelStore.GetMappedStatement(mapping.Select);

            reader = DataReaderTransformer.Transform(reader, request.Session.SessionFactory.DataSource.DbProvider);
            return(selectStatement.ExecuteQueryForObject(request.Session, keys, null));
        }
        public object GetValue(RequestScope request, ResultProperty mapping, ref IDataReader reader, object keys)
        {
            IMappedStatement mappedStatement = request.MappedStatement.SqlMap.GetMappedStatement(mapping.Select);

            if (mapping.MemberType == typeof(IList))
            {
                reader = DataReaderTransformer.Transform(reader, request.Session.DataSource.DbProvider);
                return(mappedStatement.ExecuteQueryForList(request.Session, keys));
            }
            reader = DataReaderTransformer.Transform(reader, request.Session.DataSource.DbProvider);
            object obj2 = request.DataExchangeFactory.ObjectFactory.CreateFactory(mapping.MemberType, Type.EmptyTypes).CreateInstance(null);

            mappedStatement.ExecuteQueryForList(request.Session, keys, (IList)obj2);
            return(obj2);
        }
        public object GetValue(RequestScope request, ResultProperty mapping, ref IDataReader reader, object keys)
        {
            IMappedStatement mappedStatement = request.MappedStatement.SqlMap.GetMappedStatement(mapping.Select);

            reader = DataReaderTransformer.Transform(reader, request.Session.DataSource.DbProvider);
            IList list  = mappedStatement.ExecuteQueryForList(request.Session, keys);
            Array array = Array.CreateInstance(mapping.MemberType.GetElementType(), list.Count);
            int   count = list.Count;

            for (int i = 0; i < count; i++)
            {
                array.SetValue(list[i], i);
            }
            return(array);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Gets the value of an argument constructor.
        /// </summary>
        /// <param name="request">The current <see cref="RequestScope"/>.</param>
        /// <param name="mapping">The <see cref="ResultProperty"/> with the argument infos.</param>
        /// <param name="reader">The current <see cref="IDataReader"/>.</param>
        /// <param name="keys">The keys</param>
        /// <returns>The paremeter value.</returns>
        public object GetValue(RequestScope request, ResultProperty mapping,
                               ref IDataReader reader, object keys)
        {
            // Get the select statement
            IMappedStatement selectStatement = request.MappedStatement.ModelStore.GetMappedStatement(mapping.Select);

            if (mapping.MemberType == typeof(IList))
            {
                reader = DataReaderTransformer.Transform(reader, request.Session.SessionFactory.DataSource.DbProvider);
                return(selectStatement.ExecuteQueryForList(request.Session, keys));
            }
            reader = DataReaderTransformer.Transform(reader, request.Session.SessionFactory.DataSource.DbProvider);
            IFactory factory = request.DataExchangeFactory.ObjectFactory.CreateFactory(mapping.MemberType, Type.EmptyTypes);
            object   values  = factory.CreateInstance(null);

            selectStatement.ExecuteQueryForList(request.Session, keys, (IList)values);
            return(values);
        }
        /// <summary>
        /// Gets the value of an argument constructor.
        /// </summary>
        /// <param name="request">The current <see cref="RequestScope"/>.</param>
        /// <param name="mapping">The <see cref="ResultProperty"/> with the argument infos.</param>
        /// <param name="reader">The current <see cref="IDataReader"/>.</param>
        /// <param name="keys">The keys</param>
        /// <returns>The paremeter value.</returns>
        public object GetValue(RequestScope request, ResultProperty mapping,
                               ref IDataReader reader, object keys)
        {
            // Get the select statement
            IMappedStatement selectStatement = request.MappedStatement.ModelStore.GetMappedStatement(mapping.Select);

            reader = DataReaderTransformer.Transform(reader, request.Session.SessionFactory.DataSource.DbProvider);
            IList values = selectStatement.ExecuteQueryForList(request.Session, keys);

            Type  elementType = mapping.MemberType.GetElementType();
            Array array       = Array.CreateInstance(elementType, values.Count);
            int   count       = values.Count;

            for (int i = 0; i < count; i++)
            {
                array.SetValue(values[i], i);
            }
            return(array);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Gets the value of an argument constructor.
        /// </summary>
        /// <param name="request">The current <see cref="RequestScope"/>.</param>
        /// <param name="mapping">The <see cref="ResultProperty"/> with the argument infos.</param>
        /// <param name="reader">The current <see cref="IDataReader"/>.</param>
        /// <param name="keys">The keys</param>
        /// <returns>The paremeter value.</returns>
        public object GetValue(RequestScope request, ResultProperty mapping,
                               ref IDataReader reader, object keys)
        {
            // Get the select statement
            IMappedStatement selectStatement = request.MappedStatement.ModelStore.GetMappedStatement(mapping.Select);

            reader = DataReaderTransformer.Transform(reader, request.Session.SessionFactory.DataSource.DbProvider);

            //Type[] typeArgs = mapping.MemberType.GetGenericArguments();
            //Type genericList = typeof(IList<>);
            //Type constructedType = genericList.MakeGenericType(typeArgs);
            Type elementType = mapping.MemberType.GetGenericArguments()[0];

            Type mappedStatementType = selectStatement.GetType();

            //Type[] typeArguments = { typeof(ISession), typeof(object) };

            MethodInfo[] mis = mappedStatementType.GetMethods(BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance);
            MethodInfo   mi  = null;

            for (int i = 0; i < mis.Length; i++)
            {
                if (mis[i].IsGenericMethod &&
                    mis[i].Name == "ExecuteQueryForList" &&
                    mis[i].GetParameters().Length == 2)
                {
                    mi = mis[i];
                    break;
                }
            }

            MethodInfo miConstructed = mi.MakeGenericMethod(elementType);

            // Invoke the method.
            object[] args   = { request.Session, keys };
            object   values = miConstructed.Invoke(selectStatement, args);

            return(values);
        }