public int Insert <T>(T model) { string sql = SqlMapper.CreateInsertMethod(model, SqlMapper.GetHashKey(connectionString, GetDataMap <T>().tableName)); return(CommandImpl(sql)); }
//根和聚合集合 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); }
public int Update <T>(T model, string where) { string sql = SqlMapper.CreateUpdateMethod(model, SqlMapper.GetHashKey(connectionString, GetDataMap <T>().tableName + where)); return(CommandImpl(sql)); }
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); }