Beispiel #1
0
        public int Insert <T>(T model)
        {
            string sql = SqlMapper.CreateInsertMethod(model, SqlMapper.GetHashKey(connectionString, GetDataMap <T>().tableName));

            return(CommandImpl(sql));
        }
Beispiel #2
0
        //根和聚合集合
        public TReturn Query <TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TReturn>(string querySql, Delegate act, object paramters = null) where TReturn : new()
        {
            TReturn            tReturn = new TReturn();
            List <DbParameter> param   = CreateParater(paramters);
            var reader = this.QueryCommandReader(querySql, param.ToArray());

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    tReturn = SqlMapper.MultiMap <TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TReturn>(act, reader, SqlMapper.GetHashKey(connectionString, querySql));
                }
            }
            reader.Close();
            return(tReturn);
        }
Beispiel #3
0
        public int Update <T>(T model, string where)
        {
            string sql = SqlMapper.CreateUpdateMethod(model, SqlMapper.GetHashKey(connectionString, GetDataMap <T>().tableName + where));

            return(CommandImpl(sql));
        }
Beispiel #4
0
        private List <DbParameter> CreateParater(object paramters)
        {
            List <DbParameter> param = new List <DbParameter>();
            Type paramtersType       = null;

            if (!paramters.IsNullOrSpace())
            {
                paramtersType = paramters.GetType();
                param         = SqlMapper.GetParams(paramters, paramtersType, dbprovider, SqlMapper.GetHashKey(this.connectionString, paramtersType));
            }

            return(param);
        }