public static Task <int> DeleteByEntityAsync(this IDbConnection connection, object persistentObject, Type type, IDbTransaction transaction = null, int?commandTimeout = null, CommandType?commandType = null) { var id = TypeMapInfoHelper.GetIdValue(persistentObject); return(DeleteByIdAsync(connection, id, type, transaction, commandTimeout, commandType)); }
public static IList <T> Take <T>(this IDbConnection connection, int count, IDbTransaction transaction = null, bool buffered = true, int?commandTimeout = null, CommandType?commandType = null) { var adapter = GetSqlAdapter(connection); var type = typeof(T); var sb = new StringBuilder(adapter.GetSelectSql(type, CriteriaType.None).Trim()); sb.Insert(6, $" TOP {count}").Append($" ORDER BY {TypeMapInfoHelper.GetTypeMapInfo(type).IdColumnName}"); return(connection.Query <T>(sb.ToString(), null, transaction, buffered, commandTimeout, commandType).ToList()); }