Example #1
0
        public static DbParameter[] BuildDbParameters <T>(string cmdText, T entity, Func <DbParameter> dbParamConstructor, InputMap <T> map, char sqlParamSplitter)
            where T : class
        {
            List <string> list = Analyst.GetSqlParamNameList(cmdText);
            List <ParameterProperty <T> > maps = (map == null) ? null : map.GetMaps();

            if (maps == null)
            {
                maps = new List <ParameterProperty <T> >(0);
            }
            List <DbParameter> pList = new List <DbParameter>(list.Count);

            foreach (string pName in list)
            {
                DbParameter parm = dbParamConstructor();
                parm.ParameterName = pName;
                ParameterProperty <T> pp = maps.Find(p => p.Parameter == pName);

                string[] proArray;
                if (pp != null)
                {
                    proArray = pp.PropertyList.ToArray();
                }
                else
                {
                    proArray = pName.Split(sqlParamSplitter);
                }
                object tmp = GetFieldValueAllowNull(entity, proArray);
                parm.Value = (tmp == null ? DBNull.Value : tmp);
                pList.Add(parm);
            }
            return(pList.ToArray());
        }
Example #2
0
 public static DbParameter[] BuildDbParameters <T, P>(string cmdText, T entity, InputMap <T> map, char sqlParamSplitter)
     where T : class
     where P : DbParameter, new()
 {
     return(BuildDbParameters <T>(cmdText, entity, () => new P(), map, sqlParamSplitter));
 }
Example #3
0
 public static DbParameter[] BuildDbParameters <T>(string cmdText, T entity, Func <DbParameter> dbParamConstructor, InputMap <T> map)
     where T : class
 {
     return(BuildDbParameters <T>(cmdText, entity, dbParamConstructor, map, '_'));
 }
Example #4
0
 public static DbParameter[] BuildDbParameters <T, P>(string cmdText, T entity, InputMap <T> map)
     where T : class
     where P : DbParameter, new()
 {
     return(BuildDbParameters <T, P>(cmdText, entity, map, '_'));
 }