private IList <T> QueryItems <T>(string column, object param, DataTable table, string[] conditions, string orderBy, bool activeOnly) where T : class, IDbQuery, new() { var dbEntity = DbEntityCache.GetDbEntity <T>(); var fields = param == null ? new ColumnField[] { } : ColumnField.GetFields(param); var tableName = WriteToServer(table); var sql = CommandTextCache.GetSplitQueryCommandText(tableName, column, dbEntity, fields, conditions, orderBy, activeOnly); return(conn.Query <T>(sql, param, tran, true, null, CommandType.Text).ToList()); }
private IList <T> QueryItems <T>(string key, object param, string[] conditions, string orderBy, bool activeOnly) where T : class, IDbQuery, new() { var sql = CommandTextCache.GetCachedCommandText(key); if (string.IsNullOrEmpty(sql)) { var dbEntity = DbEntityCache.GetDbEntity <T>(); var fields = param == null ? new ColumnField[] { } : ColumnField.GetFields(param); sql = CommandTextCache.GetMultiQueryCommandText(key, dbEntity, fields, conditions, orderBy, activeOnly); } return(conn.Query <T>(sql, param, tran, true, null, CommandType.Text).ToList()); }
public void Update <T>(T item) where T : class, IDbEntity, IDbModel, new() { ThrowIfNull(item); var key = string.Format("{0}.Update", typeof(T)); var sql = CommandTextCache.GetCachedCommandText(key); if (string.IsNullOrEmpty(sql)) { var dbEntity = DbEntityCache.GetDbEntity <T>(item); var fields = ColumnField.GetFields(item); sql = CommandTextCache.GetUpdateCommandText(key, dbEntity, fields); } conn.Execute(sql, item, tran, null, CommandType.Text); }