Permalink
Browse files

Add overloads without sql param

Give Fetch(), Query(), Page(), and SkipTake() overloads that omit the
string sql parameter, so that PetaPoco will do SELECT *
  • Loading branch information...
asherber authored and pleb committed Oct 29, 2018
1 parent 226a41d commit c86d31cf01e79006e73dc94ec1e8c2520ff0ee6d
Showing with 119 additions and 0 deletions.
  1. +59 −0 PetaPoco/Database.cs
  2. +60 −0 PetaPoco/IQuery.cs
@@ -733,6 +733,13 @@ public T ExecuteScalar<T>(Sql sql)
#region operation: Fetch
/// <summary>
/// Runs a SELECT * query and returns the result set as a typed list
/// </summary>
/// <typeparam name="T">The Type representing a row in the result set</typeparam>
/// <returns>A List holding the results of the query</returns>
public List<T> Fetch<T>() => Fetch<T>(String.Empty);
/// <summary>
/// Runs a query and returns the result set as a typed list
/// </summary>
@@ -828,6 +835,20 @@ public Page<T> Page<T>(long page, long itemsPerPage, string sqlCount, object[] c
return result;
}
/// <summary>
/// Retrieves a page of records and the total number of available records
/// </summary>
/// <typeparam name="T">The Type representing a row in the result set</typeparam>
/// <param name="page">The 1 based page number to retrieve</param>
/// <param name="itemsPerPage">The number of records per page</param>
/// <returns>A Page of results</returns>
/// <remarks>
/// PetaPoco will automatically modify a default SELECT * statement to only retrieve the
/// records for the specified page. It will also execute a second query to retrieve the
/// total number of records in the result set.
/// </remarks>
public Page<T> Page<T>(long page, long itemsPerPage) => Page<T>(page, itemsPerPage, String.Empty);
/// <summary>
/// Retrieves a page of records and the total number of available records
/// </summary>
@@ -890,6 +911,19 @@ public Page<T> Page<T>(long page, long itemsPerPage, Sql sqlCount, Sql sqlPage)
#region operation: Fetch (page)
/// <summary>
/// Retrieves a page of records (without the total count)
/// </summary>
/// <typeparam name="T">The Type representing a row in the result set</typeparam>
/// <param name="page">The 1 based page number to retrieve</param>
/// <param name="itemsPerPage">The number of records per page</param>
/// <returns>A List of results</returns>
/// <remarks>
/// PetaPoco will automatically modify a default SELECT * statement to only retrieve the
/// records for the specified page.
/// </remarks>
public List<T> Fetch<T>(long page, long itemsPerPage) => Fetch<T>(page, itemsPerPage, String.Empty);
/// <summary>
/// Retrieves a page of records (without the total count)
/// </summary>
@@ -929,6 +963,19 @@ public List<T> Fetch<T>(long page, long itemsPerPage, Sql sql)
#region operation: SkipTake
/// <summary>
/// Retrieves a range of records from result set
/// </summary>
/// <typeparam name="T">The Type representing a row in the result set</typeparam>
/// <param name="skip">The number of rows at the start of the result set to skip over</param>
/// <param name="take">The number of rows to retrieve</param>
/// <returns>A List of results</returns>
/// <remarks>
/// PetaPoco will automatically modify a default SELECT * statement to only retrieve the
/// records for the specified range.
/// </remarks>
public List<T> SkipTake<T>(long skip, long take) => SkipTake<T>(skip, take, String.Empty);
/// <summary>
/// Retrieves a range of records from result set
/// </summary>
@@ -970,6 +1017,18 @@ public List<T> SkipTake<T>(long skip, long take, Sql sql)
#region operation: Query
/// <summary>
/// Runs a SELECT * query, returning the results as an IEnumerable collection
/// </summary>
/// <typeparam name="T">The Type representing a row in the result set</typeparam>
/// <returns>An enumerable collection of result records</returns>
/// <remarks>
/// For some DB providers, care should be taken to not start a new Query before finishing with
/// and disposing the previous one. In cases where this is an issue, consider using Fetch which
/// returns the results as a List rather than an IEnumerable.
/// </remarks>
public IEnumerable<T> Query<T>() => Query<T>(String.Empty);
/// <summary>
/// Runs an SQL query, returning the results as an IEnumerable collection
/// </summary>
@@ -11,6 +11,18 @@ namespace PetaPoco
{
public interface IQuery
{
/// <summary>
/// Runs a SELECT * query, returning the results as an IEnumerable collection
/// </summary>
/// <typeparam name="T">The Type representing a row in the result set</typeparam>
/// <returns>An enumerable collection of result records</returns>
/// <remarks>
/// For some DB providers, care should be taken to not start a new Query before finishing with
/// and disposing the previous one. In cases where this is an issue, consider using Fetch which
/// returns the results as a List rather than an IEnumerable.
/// </remarks>
IEnumerable<T> Query<T>();
/// <summary>
/// Runs an SQL query, returning the results as an IEnumerable collection
/// </summary>
@@ -241,6 +253,13 @@ public interface IQuery
/// <returns>A collection of POCO's as an IEnumerable</returns>
IEnumerable<TRet> Query<TRet>(Type[] types, object cb, string sql, params object[] args);
/// <summary>
/// Runs a SELECT * query and returns the result set as a typed list
/// </summary>
/// <typeparam name="T">The Type representing a row in the result set</typeparam>
/// <returns>A List holding the results of the query</returns>
List<T> Fetch<T>();
/// <summary>
/// Runs a query and returns the result set as a typed list
/// </summary>
@@ -276,6 +295,20 @@ public interface IQuery
/// </remarks>
Page<T> Page<T>(long page, long itemsPerPage, string sqlCount, object[] countArgs, string sqlPage, object[] pageArgs);
/// <summary>
/// Retrieves a page of records and the total number of available records
/// </summary>
/// <typeparam name="T">The Type representing a row in the result set</typeparam>
/// <param name="page">The 1 based page number to retrieve</param>
/// <param name="itemsPerPage">The number of records per page</param>
/// <returns>A Page of results</returns>
/// <remarks>
/// PetaPoco will automatically modify a default SELECT * statement to only retrieve the
/// records for the specified page. It will also execute a second query to retrieve the
/// total number of records in the result set.
/// </remarks>
Page<T> Page<T>(long page, long itemsPerPage);
/// <summary>
/// Retrieves a page of records and the total number of available records
/// </summary>
@@ -323,6 +356,19 @@ public interface IQuery
/// </remarks>
Page<T> Page<T>(long page, long itemsPerPage, Sql sqlCount, Sql sqlPage);
/// <summary>
/// Retrieves a page of records (without the total count)
/// </summary>
/// <typeparam name="T">The Type representing a row in the result set</typeparam>
/// <param name="page">The 1 based page number to retrieve</param>
/// <param name="itemsPerPage">The number of records per page</param>
/// <returns>A List of results</returns>
/// <remarks>
/// PetaPoco will automatically modify a default SELECT * statement to only retrieve the
/// records for the specified page.
/// </remarks>
List<T> Fetch<T>(long page, long itemsPerPage);
/// <summary>
/// Retrieves a page of records (without the total count)
/// </summary>
@@ -352,6 +398,20 @@ public interface IQuery
/// </remarks>
List<T> Fetch<T>(long page, long itemsPerPage, Sql sql);
/// <summary>
/// Retrieves a range of records from result set
/// </summary>
/// <typeparam name="T">The Type representing a row in the result set</typeparam>
/// <param name="skip">The number of rows at the start of the result set to skip over</param>
/// <param name="take">The number of rows to retrieve</param>
/// <returns>A List of results</returns>
/// <remarks>
/// PetaPoco will automatically modify a default SELECT * statement to only retrieve the
/// records for the specified range.
/// </remarks>
List<T> SkipTake<T>(long skip, long take);
/// <summary>
/// Retrieves a range of records from result set
/// </summary>

0 comments on commit c86d31c

Please sign in to comment.