Beispiel #1
0
        public bool CanProcess(Context.Infrastructure.AdoExecutorContext context)
        {
            if (_sqlPrimitiveDataTypes.IsSqlPrimitiveType(context.ParametersType))
            {
                return(false);
            }

            return(context.Parameters is IEnumerable);
        }
Beispiel #2
0
        public void ExtractParameter(Context.Infrastructure.AdoExecutorContext context)
        {
            var parameters = (IDictionary <string, object>)context.Parameters;

            foreach (var parameter in parameters)
            {
                if (string.IsNullOrEmpty(parameter.Key))
                {
                    throw new AdoExecutorException("Dictionary item key cannot be null or empty.");
                }

                if (parameter.Value == null)
                {
                    throw new AdoExecutorException("Dictionary item value cannot be null.");
                }

                var parameterType = parameter.Value.GetType();

                if (!_sqlPrimitiveDataTypes.IsSqlPrimitiveType(parameterType))
                {
                    throw new AdoExecutorException("Array item must be sql primitive type.");
                }

                IDbDataParameter dataParameter = context.Configuration.DataObjectFactory.CreateDataParameter();
                dataParameter.ParameterName = parameter.Key;
                dataParameter.Value         = parameter.Value;

                context.Command.Parameters.Add(dataParameter);
            }
        }
        public bool CanProcess(ObjectBuilderContext context)
        {
            if (_sqlPrimitiveDataTypes.IsSqlPrimitiveType(context.ResultType))
            {
                return(true);
            }

            return(false);
        }
        public bool CanProcess(ObjectBuilderContext context)
        {
            if (context.ResultType.IsAbstract || context.ResultType.IsInterface)
            {
                return(false);
            }

            if (Nullable.GetUnderlyingType(context.ResultType) != null)
            {
                return(false);
            }

            if (context.ResultType.GetInterface(typeof(IEnumerable).FullName) != null)
            {
                return(false);
            }

            if (context.ResultType == typeof(object))
            {
                return(false);
            }

            if (_sqlPrimitiveDataTypes.IsSqlPrimitiveType(context.ResultType))
            {
                return(false);
            }

            if (context.ResultType.GetConstructor(Type.EmptyTypes) == null)
            {
                return(false);
            }

            if (context.ResultType == typeof(DataTable) || context.ResultType == typeof(DataSet))
            {
                return(false);
            }

            return(true);
        }