예제 #1
0
        public void BuildParameters(IDbCommand cmd, object param)
        {
            foreach (var accessor in metadataFactory.Create(param.GetType()).GetParameterAccessors())
            {
                var parameter = cmd.CreateParameter();
                parameter.ParameterName = accessor.Name;
                var value = accessor.GetValue(param) ?? DBNull.Value;
                parameter.DbType = dbTypeMap.LookupDbType(accessor.Type);
                parameter.Value  = value;

                cmd.Parameters.Add(parameter);
            }
        }
예제 #2
0
        public void BuildParameters(IDbCommand cmd, object param)
        {
            foreach (var keyValue in (IDictionary <string, Object>)param)
            {
                var parameter = cmd.CreateParameter();
                parameter.ParameterName = keyValue.Key;
                var value = keyValue.Value ?? DBNull.Value;
                if (value != DBNull.Value)
                {
                    parameter.DbType = dbTypeMap.LookupDbType(value);
                }
                parameter.Value = value;

                cmd.Parameters.Add(parameter);
            }
        }
예제 #3
0
        void IDynamicParameter.BuildParameters(IDbCommand cmd)
        {
            foreach (var param in parameters.Values)
            {
                var parameter = cmd.CreateParameter();
                cmd.Parameters.Add(parameter);

                param.AttachedParam = parameter;

                parameter.ParameterName = param.Name;
                parameter.Value         = param.Value ?? DBNull.Value;
                parameter.DbType        = param.DbType ?? dbTypeMap.LookupDbType(param.Value);
                if (param.Size.HasValue)
                {
                    parameter.Size = param.Size.Value;
                }
                parameter.Direction = param.Direction;
            }
        }