// -------------------------------------------------
        //                              Common of OutsideSql
        //                              --------------------
        protected Type GetOutsideSqlDefaultBeanClass(MethodInfo mi)
        {
            Type retType = mi.ReturnType;

            if (retType.IsGenericType && (retType.GetGenericTypeDefinition().Equals(typeof(System.Collections.Generic.IList <>))))
            {
                return(retType.GetGenericArguments()[0]);
            }
            else if (!retType.IsGenericType && typeof(System.Collections.IList).IsAssignableFrom(retType))
            {
                return(_beanType);
            }
            else if (retType.IsArray)
            {
                return(retType.GetElementType());
            }
            else if (ValueTypes.GetValueType(retType) != ValueTypes.OBJECT)
            {
                return(_beanType);
            }
            else
            {
                return(retType);
            }
        }
        // ===============================================================================
        //                                                          ConditionBean Override
        //                                                          ======================
        protected override void SetupSelectMethodByAuto(MethodInfo methodInfo)
        {
            if (SetupInternalSelectMethodSequenceNextVal(methodInfo))
            {
                return;
            }

            // Assert unsupported
            String query = _annotationReader.GetQuery(methodInfo.Name);

            AssertQueryAnnotationUnsupported(methodInfo, query);

            IDataReaderHandler handler = CreateDataReaderHandler(methodInfo);

            String[]             argNames = MethodUtil.GetParameterNames(methodInfo);
            Type[]               argTypes = MethodUtil.GetParameterTypes(methodInfo);
            SelectDynamicCommand cmd      = CreateSelectDynamicCommand(handler);

            if (argTypes.Length == 1 && ValueTypes.GetValueType(argTypes[0]) == ValueTypes.OBJECT)
            {
                argNames = new String[] { "pmb" };
                AssertAutoQueryByDtoUnsupported(methodInfo, argTypes);
                S2DaoSelectDynamicCommand dynamicCommand = CreateCustomizeSelectDynamicCommand(handler);
                cmd = dynamicCommand;
            }
            else
            {
                HandleAutoQueryByArgsAnnotationUnsupported(methodInfo, argNames);
            }
            cmd.ArgNames = argNames;
            cmd.ArgTypes = argTypes;
            _sqlCommands[methodInfo.Name] = cmd;
        }
Exemplo n.º 3
0
        public static void AddValueType()
        {
            IValueType objType = ValueTypes.GetValueType(null);

            if (ValueTypes.GetValueType(typeof(UInt32)) == objType)
            {
                ValueTypes.RegisterValueType(typeof(UInt32), UINT32);
            }
            if (ValueTypes.GetValueType(typeof(Nullable <UInt32>)) == objType)
            {
                ValueTypes.RegisterValueType(typeof(Nullable <UInt32>), NULLABLE_UINT32);
            }
        }
        protected IDataReaderHandler CreateSpecifiedOutsideSqlCustomizeBeanListResultSetHandler(IBeanMetaData specifiedBeanMetaData, Type customizeEntityType)
        {
            IValueType valueType = ValueTypes.GetValueType(customizeEntityType);

            if (valueType == null || !valueType.Equals(ValueTypes.OBJECT))
            {
                // Non generic because it cannot add the null value to generic list by abstract type.
                return(new InternalObjectListResultSetHandler(customizeEntityType, valueType));
            }
            InternalRowCreator         rowCreator         = CreateInternalRowCreator(specifiedBeanMetaData); // For performance turning!
            InternalRelationRowCreator relationRowCreator = CreateInternalRelationRowCreator(specifiedBeanMetaData);

            return(new InternalBeanGenericListMetaDataResultSetHandler(specifiedBeanMetaData, rowCreator, relationRowCreator));
        }
        protected IPropertyType CreatePropertyTypeExtension(PropertyInfo pi, DBMeta dbmeta)
        {
            if (IsRelationProperty(pi, dbmeta))
            {
                return(null);
            }
            String        columnName = GetPropertyTypeColumnName(pi);
            IValueType    valueType  = ValueTypes.GetValueType(pi.PropertyType);
            IPropertyType pt         = new PropertyTypeImpl(pi, valueType, columnName);

            if (dbmeta.HasPrimaryKey && dbmeta.HasColumn(pt.ColumnName))
            {
                if (dbmeta.FindColumnInfo(pt.ColumnName).IsPrimary)
                {
                    pt.IsPrimaryKey = true;
                }
            }
            pt.IsPersistent = IsPersistentProperty(pi, dbmeta);
            return(pt);
        }
Exemplo n.º 6
0
 // ===============================================================================
 //                                                                    Common Logic
 //                                                                    ============
 // -------------------------------------------------
 //                                     Args Handling
 //                                     -------------
 protected virtual void BindArgs(IDbCommand command, Object[] args, Type[] argTypes)
 {
     if (_loggingMessageSqlArgs == null)
     {
         _loggingMessageSqlArgs = args;
     }                                                                      // Save arguments for logging.
     if (args == null)
     {
         return;
     }
     string[] argNames = _commandFactory.GetArgNames(command, args);
     for (int i = 0; i < args.Length; ++i)
     {
         IValueType valueType = ValueTypes.GetValueType(argTypes[i]);
         try {
             valueType.BindValue(command, argNames[i], args[i]);
         } catch (Exception e) {
             HandleDbException(e, command);
         }
     }
 }