diff --git a/PetaPoco/Core/ColumnInfo.cs b/PetaPoco/Core/ColumnInfo.cs
index 8168691b..afa7d6f0 100644
--- a/PetaPoco/Core/ColumnInfo.cs
+++ b/PetaPoco/Core/ColumnInfo.cs
@@ -92,6 +92,18 @@ public class ColumnInfo
///
public string UpdateTemplate { get; set; }
+ ///
+ /// Creates and populates a ColumnInfo from the attributes of a POCO property.
+ ///
+ /// The POCO property to use for initializing the ColumnInfo.
+ /// A ColumnInfo instance.
+ public static ColumnInfo FromProperty(PropertyInfo propertyInfo)
+ {
+ var ci = new ColumnInfo();
+ PopulateFromProperty(propertyInfo, ref ci, out _);
+ return ci;
+ }
+
internal static void PopulateFromProperty(PropertyInfo pi, ref ColumnInfo ci, out ColumnAttribute columnAttr)
{
// Check if declaring poco has [Explicit] attribute
@@ -123,17 +135,5 @@ internal static void PopulateFromProperty(PropertyInfo pi, ref ColumnInfo ci, ou
}
}
}
-
- ///
- /// Creates and populates a ColumnInfo from the attributes of a POCO property.
- ///
- /// The POCO property to use for initializing the ColumnInfo.
- /// A ColumnInfo instance.
- public static ColumnInfo FromProperty(PropertyInfo propertyInfo)
- {
- var ci = new ColumnInfo();
- PopulateFromProperty(propertyInfo, ref ci, out _);
- return ci;
- }
}
}
diff --git a/PetaPoco/Core/IGridReader.cs b/PetaPoco/Core/IGridReader.cs
index a2406075..1681dec3 100644
--- a/PetaPoco/Core/IGridReader.cs
+++ b/PetaPoco/Core/IGridReader.cs
@@ -8,6 +8,8 @@ namespace PetaPoco
///
public interface IGridReader : IDisposable
{
+ #region ReadSinglePoco
+
///
/// Performs a read, returning the results as an collection.
///
@@ -15,6 +17,10 @@ public interface IGridReader : IDisposable
/// An enumerable collection of POCOs containing the result records.
IEnumerable Read();
+ #endregion
+
+ #region ReadMultiPoco : auto-mapping
+
///
IEnumerable Read();
@@ -31,6 +37,10 @@ public interface IGridReader : IDisposable
/// An enumerable collection of POCOs containing the result records.
IEnumerable Read();
+ #endregion
+
+ #region ReadMultiPoco : custom-mapping
+
///
IEnumerable Read(Func func);
@@ -48,5 +58,7 @@ public interface IGridReader : IDisposable
/// A callback function to used to connect the POCO instances, or to let PetaPoco automatically deduce the relationships.
/// An enumerable collection of POCOs containing the result records.
IEnumerable Read(Func func);
+
+ #endregion
}
}
diff --git a/PetaPoco/Core/PocoData.cs b/PetaPoco/Core/PocoData.cs
index 255f4ef0..a9e9ac31 100644
--- a/PetaPoco/Core/PocoData.cs
+++ b/PetaPoco/Core/PocoData.cs
@@ -74,6 +74,14 @@ public PocoData(Type type, IMapper defaultMapper)
QueryColumns = (from c in Columns where !c.Value.ResultColumn || c.Value.AutoSelectedResultColumn select c.Key).ToArray();
}
+ public static PocoData ForType(Type type, IMapper defaultMapper)
+ {
+ if (type == typeof(System.Dynamic.ExpandoObject))
+ throw new InvalidOperationException("Can't use dynamic types with this method");
+
+ return _pocoDatas.GetOrAdd(type, () => new PocoData(type, defaultMapper));
+ }
+
public static PocoData ForObject(object obj, string primaryKeyName, IMapper defaultMapper)
{
var t = obj.GetType();
@@ -97,20 +105,6 @@ public static PocoData ForObject(object obj, string primaryKeyName, IMapper defa
return ForType(t, defaultMapper);
}
- public static PocoData ForType(Type type, IMapper defaultMapper)
- {
- if (type == typeof(System.Dynamic.ExpandoObject))
- throw new InvalidOperationException("Can't use dynamic types with this method");
-
- return _pocoDatas.GetOrAdd(type, () => new PocoData(type, defaultMapper));
- }
-
- private static bool IsIntegralType(Type type)
- {
- var tc = Type.GetTypeCode(type);
- return tc >= TypeCode.SByte && tc <= TypeCode.UInt64;
- }
-
// Create factory function that can convert a IDataReader record into a POCO
public Delegate GetFactory(string sql, string connectionString, int firstColumn, int countColumns, IDataReader reader, IMapper defaultMapper)
{
@@ -393,6 +387,12 @@ private static Func GetConverter(IMapper mapper, PocoColumn pc,
return null;
}
+ private static bool IsIntegralType(Type type)
+ {
+ var tc = Type.GetTypeCode(type);
+ return tc >= TypeCode.SByte && tc <= TypeCode.UInt64;
+ }
+
private static T RecurseInheritedTypes(Type t, Func cb)
{
while (t != null)
diff --git a/PetaPoco/DatabaseConfigurationExtensions.cs b/PetaPoco/DatabaseConfigurationExtensions.cs
index 85d40bfe..5fa286ea 100644
--- a/PetaPoco/DatabaseConfigurationExtensions.cs
+++ b/PetaPoco/DatabaseConfigurationExtensions.cs
@@ -12,13 +12,13 @@ public static class DatabaseConfigurationExtensions
internal const string CommandTimeout = "CommandTimeout";
internal const string EnableAutoSelect = "EnableAutoSelect";
internal const string EnableNamedParams = "EnableNamedParams";
- internal const string Provider = "Provider";
- internal const string ConnectionString = "ConnectionString";
- internal const string ProviderName = "ProviderName";
#if !NETSTANDARD
internal const string ConnectionStringName = "ConnectionStringName";
#endif
+ internal const string ConnectionString = "ConnectionString";
+ internal const string ProviderName = "ProviderName";
+ internal const string Provider = "Provider";
internal const string DefaultMapper = "DefaultMapper";
internal const string IsolationLevel = "IsolationLevel";
@@ -37,6 +37,8 @@ private static void SetSetting(this IDatabaseBuildConfiguration source, string k
((IBuildConfigurationSettings) source).SetSetting(key, value);
}
+ #region Timeout Settings
+
///
/// Adds a command timeout - see .
///
@@ -52,208 +54,223 @@ public static IDatabaseBuildConfiguration UsingCommandTimeout(this IDatabaseBuil
return source;
}
+ #endregion
+
+ #region AutoSelect Settings
+
///
- /// Enables named params - see .
+ /// Enables auto select .
///
/// The configuration source.
/// The original configuration, to form a fluent interface.
- public static IDatabaseBuildConfiguration WithNamedParams(this IDatabaseBuildConfiguration source)
+ public static IDatabaseBuildConfiguration WithAutoSelect(this IDatabaseBuildConfiguration source)
{
- source.SetSetting(EnableNamedParams, true);
+ source.SetSetting(EnableAutoSelect, true);
return source;
}
///
- /// Disables named params - see .
+ /// Disables auto select - see .
///
/// The configuration source.
/// The original configuration, to form a fluent interface.
- public static IDatabaseBuildConfiguration WithoutNamedParams(this IDatabaseBuildConfiguration source)
+ public static IDatabaseBuildConfiguration WithoutAutoSelect(this IDatabaseBuildConfiguration source)
{
- source.SetSetting(EnableNamedParams, false);
+ source.SetSetting(EnableAutoSelect, false);
return source;
}
+ #endregion
+
+ #region NamedParams Settings
+
///
- /// Specifies the provider to be used. - see . This takes precedence over .
+ /// Enables named params - see .
///
/// The configuration source.
- /// The provider to use.
/// The original configuration, to form a fluent interface.
- /// Thrown when is null.
- public static IDatabaseBuildConfiguration UsingProvider(this IDatabaseBuildConfiguration source, T provider) where T : class, IProvider
+ public static IDatabaseBuildConfiguration WithNamedParams(this IDatabaseBuildConfiguration source)
{
- if (provider == null)
- throw new ArgumentNullException(nameof(provider));
- source.SetSetting(Provider, provider);
+ source.SetSetting(EnableNamedParams, true);
return source;
}
///
- /// Specifies the provider to be used. - see . This takes precedence over .
+ /// Disables named params - see .
///
- /// The provider type.
/// The configuration source.
- /// The configure provider callback.
- /// The provider to use.
/// The original configuration, to form a fluent interface.
- /// Thrown when is null.
- /// Thrown when is null.
- public static IDatabaseBuildConfiguration UsingProvider(this IDatabaseBuildConfiguration source, T provider, Action configure) where T : class, IProvider
+ public static IDatabaseBuildConfiguration WithoutNamedParams(this IDatabaseBuildConfiguration source)
{
- if (provider == null)
- throw new ArgumentNullException(nameof(provider));
- if (configure == null)
- throw new ArgumentNullException(nameof(configure));
- configure(provider);
- source.SetSetting(Provider, provider);
+ source.SetSetting(EnableNamedParams, false);
return source;
}
+ #endregion
+
+ #region Connection Settings
+
+#if !NETSTANDARD
///
- /// Specifies the provider to be used. - see . This takes precedence over .
+ /// Adds a connection string name.
///
- /// The provider type.
/// The configuration source.
+ /// The connection string name.
/// The original configuration, to form a fluent interface.
- public static IDatabaseBuildConfiguration UsingProvider(this IDatabaseBuildConfiguration source) where T : class, IProvider, new()
+ /// Thrown when is null or empty.
+ public static IDatabaseBuildConfiguration UsingConnectionStringName(this IDatabaseBuildConfiguration source, string connectionStringName)
{
- source.SetSetting(Provider, new T());
+ if (string.IsNullOrEmpty(connectionStringName))
+ throw new ArgumentException("Argument is null or empty", nameof(connectionStringName));
+ source.SetSetting(ConnectionStringName, connectionStringName);
return source;
}
+#endif
///
- /// Specifies the to use, with an accompanying configuration provider custom callback.
+ /// Adds a connection string - see .
///
- /// The provider type, constrained to a class deriving from .
/// The configuration source.
- /// The configure provider callback.
+ /// The connection string.
/// The original configuration, to form a fluent interface.
- /// Thrown when is null.
- public static IDatabaseBuildConfiguration UsingProvider(this IDatabaseBuildConfiguration source, Action configure) where T : class, IProvider, new()
+ /// Thrown when is null or empty.
+ public static IDatabaseBuildConfiguration UsingConnectionString(this IDatabaseBuildConfiguration source, string connectionString)
{
- if (configure == null)
- throw new ArgumentNullException(nameof(configure));
- var provider = new T();
- configure(provider);
- source.SetSetting(Provider, provider);
+ if (string.IsNullOrEmpty(connectionString))
+ throw new ArgumentException("Argument is null or empty", nameof(connectionString));
+ source.SetSetting(ConnectionString, connectionString);
return source;
}
///
- /// Enables auto select .
+ /// Specifies an to use.
///
/// The configuration source.
+ /// The connection to use.
/// The original configuration, to form a fluent interface.
- public static IDatabaseBuildConfiguration WithAutoSelect(this IDatabaseBuildConfiguration source)
+ public static IDatabaseBuildConfiguration UsingConnection(this IDatabaseBuildConfiguration source, IDbConnection connection)
{
- source.SetSetting(EnableAutoSelect, true);
+ if (connection == null)
+ throw new ArgumentNullException(nameof(connection));
+
+ source.SetSetting(Connection, connection);
return source;
}
+ #endregion
+
+ #region Provider Settings
+
///
- /// Disables auto select - see .
+ /// Adds a provider name string - see .
///
/// The configuration source.
+ /// The provider name.
/// The original configuration, to form a fluent interface.
- public static IDatabaseBuildConfiguration WithoutAutoSelect(this IDatabaseBuildConfiguration source)
+ /// Thrown when is null or empty.
+ public static IDatabaseBuildConfiguration UsingProviderName(this IDatabaseBuildConfiguration source, string providerName)
{
- source.SetSetting(EnableAutoSelect, false);
+ if (string.IsNullOrEmpty(providerName))
+ throw new ArgumentException("Argument is null or empty", nameof(providerName));
+ source.SetSetting(ProviderName, providerName);
return source;
}
///
- /// Adds a connection string - see .
+ /// Specifies the provider to be used. - see . This takes precedence over .
///
+ /// The provider type.
/// The configuration source.
- /// The connection string.
/// The original configuration, to form a fluent interface.
- /// Thrown when is null or empty.
- public static IDatabaseBuildConfiguration UsingConnectionString(this IDatabaseBuildConfiguration source, string connectionString)
+ public static IDatabaseBuildConfiguration UsingProvider(this IDatabaseBuildConfiguration source) where T : class, IProvider, new()
{
- if (string.IsNullOrEmpty(connectionString))
- throw new ArgumentException("Argument is null or empty", nameof(connectionString));
- source.SetSetting(ConnectionString, connectionString);
+ source.SetSetting(Provider, new T());
return source;
}
-#if !NETSTANDARD
///
- /// Adds a connection string name.
+ /// Specifies the to use, with an accompanying configuration provider custom callback.
///
+ /// The provider type, constrained to a class deriving from .
/// The configuration source.
- /// The connection string name.
+ /// The configure provider callback.
/// The original configuration, to form a fluent interface.
- /// Thrown when is null or empty.
- public static IDatabaseBuildConfiguration UsingConnectionStringName(this IDatabaseBuildConfiguration source, string connectionStringName)
+ /// Thrown when is null.
+ public static IDatabaseBuildConfiguration UsingProvider(this IDatabaseBuildConfiguration source, Action configure) where T : class, IProvider, new()
{
- if (string.IsNullOrEmpty(connectionStringName))
- throw new ArgumentException("Argument is null or empty", nameof(connectionStringName));
- source.SetSetting(ConnectionStringName, connectionStringName);
+ if (configure == null)
+ throw new ArgumentNullException(nameof(configure));
+ var provider = new T();
+ configure(provider);
+ source.SetSetting(Provider, provider);
return source;
}
-#endif
///
- /// Adds a provider name string - see .
+ /// Specifies the provider to be used. - see . This takes precedence over .
///
/// The configuration source.
- /// The provider name.
+ /// The provider to use.
/// The original configuration, to form a fluent interface.
- /// Thrown when is null or empty.
- public static IDatabaseBuildConfiguration UsingProviderName(this IDatabaseBuildConfiguration source, string providerName)
+ /// Thrown when is null.
+ public static IDatabaseBuildConfiguration UsingProvider(this IDatabaseBuildConfiguration source, T provider) where T : class, IProvider
{
- if (string.IsNullOrEmpty(providerName))
- throw new ArgumentException("Argument is null or empty", nameof(providerName));
- source.SetSetting(ProviderName, providerName);
+ if (provider == null)
+ throw new ArgumentNullException(nameof(provider));
+ source.SetSetting(Provider, provider);
return source;
}
///
- /// Specifies an to use.
+ /// Specifies the provider to be used. - see . This takes precedence over .
///
+ /// The provider type.
/// The configuration source.
- /// The connection to use.
+ /// The configure provider callback.
+ /// The provider to use.
/// The original configuration, to form a fluent interface.
- public static IDatabaseBuildConfiguration UsingConnection(this IDatabaseBuildConfiguration source, IDbConnection connection)
+ /// Thrown when is null.
+ /// Thrown when is null.
+ public static IDatabaseBuildConfiguration UsingProvider(this IDatabaseBuildConfiguration source, T provider, Action configure) where T : class, IProvider
{
- if (connection == null)
- throw new ArgumentNullException(nameof(connection));
-
- source.SetSetting(Connection, connection);
+ if (provider == null)
+ throw new ArgumentNullException(nameof(provider));
+ if (configure == null)
+ throw new ArgumentNullException(nameof(configure));
+ configure(provider);
+ source.SetSetting(Provider, provider);
return source;
}
+ #endregion
+
+ #region Mapper Settings
+
///
/// Specifies the default mapper to use when no specific mapper has been registered.
///
+ /// The mapper type.
/// The configuration source.
- /// The mapper to use as the default.
/// The original configuration, to form a fluent interface.
- /// Thrown when is null.
- public static IDatabaseBuildConfiguration UsingDefaultMapper(this IDatabaseBuildConfiguration source, T mapper) where T : class, IMapper
+ public static IDatabaseBuildConfiguration UsingDefaultMapper(this IDatabaseBuildConfiguration source) where T : class, IMapper, new()
{
- if (mapper == null)
- throw new ArgumentNullException(nameof(mapper));
- source.SetSetting(DefaultMapper, mapper);
+ source.SetSetting(DefaultMapper, new T());
return source;
}
///
/// Specifies the default mapper to use when no specific mapper has been registered.
///
+ /// The type of the mapper. This type must be a class that implements the interface.
/// The configuration source.
- /// The mapper to use as the default.
- /// The configure mapper callback.
+ /// A callback function to configure the mapper.
/// The original configuration, to form a fluent interface.
- /// Thrown when is null.
- /// Thrown when is null.
- public static IDatabaseBuildConfiguration UsingDefaultMapper(this IDatabaseBuildConfiguration source, T mapper, Action configure) where T : class, IMapper
+ /// Thrown if the callback function is null.
+ public static IDatabaseBuildConfiguration UsingDefaultMapper(this IDatabaseBuildConfiguration source, Action configure) where T : class, IMapper, new()
{
- if (mapper == null)
- throw new ArgumentNullException(nameof(mapper));
if (configure == null)
throw new ArgumentNullException(nameof(configure));
+ var mapper = new T();
configure(mapper);
source.SetSetting(DefaultMapper, mapper);
return source;
@@ -262,33 +279,42 @@ public static IDatabaseBuildConfiguration UsingDefaultMapper(this IDatabaseBu
///
/// Specifies the default mapper to use when no specific mapper has been registered.
///
- /// The mapper type.
/// The configuration source.
+ /// The mapper to use as the default.
/// The original configuration, to form a fluent interface.
- public static IDatabaseBuildConfiguration UsingDefaultMapper(this IDatabaseBuildConfiguration source) where T : class, IMapper, new()
+ /// Thrown when is null.
+ public static IDatabaseBuildConfiguration UsingDefaultMapper(this IDatabaseBuildConfiguration source, T mapper) where T : class, IMapper
{
- source.SetSetting(DefaultMapper, new T());
+ if (mapper == null)
+ throw new ArgumentNullException(nameof(mapper));
+ source.SetSetting(DefaultMapper, mapper);
return source;
}
///
/// Specifies the default mapper to use when no specific mapper has been registered.
///
- /// The type of the mapper. This type must be a class that implements the interface.
/// The configuration source.
- /// A callback function to configure the mapper.
+ /// The mapper to use as the default.
+ /// The configure mapper callback.
/// The original configuration, to form a fluent interface.
- /// Thrown if the callback function is null.
- public static IDatabaseBuildConfiguration UsingDefaultMapper(this IDatabaseBuildConfiguration source, Action configure) where T : class, IMapper, new()
+ /// Thrown when is null.
+ /// Thrown when is null.
+ public static IDatabaseBuildConfiguration UsingDefaultMapper(this IDatabaseBuildConfiguration source, T mapper, Action configure) where T : class, IMapper
{
+ if (mapper == null)
+ throw new ArgumentNullException(nameof(mapper));
if (configure == null)
throw new ArgumentNullException(nameof(configure));
- var mapper = new T();
configure(mapper);
source.SetSetting(DefaultMapper, mapper);
return source;
}
+ #endregion
+
+ #region Transaction Settings
+
///
/// Specifies the transaction isolation level to use.
///
@@ -301,6 +327,10 @@ public static IDatabaseBuildConfiguration UsingIsolationLevel(this IDatabaseBuil
return source;
}
+ #endregion
+
+ #region Event Settings
+
///
/// Specifies an event handler to use when a new transaction has been started.
///
@@ -397,6 +427,10 @@ public static IDatabaseBuildConfiguration UsingExceptionThrown(this IDatabaseBui
return source;
}
+ #endregion
+
+ #region Finalize Fluent Configuration
+
///
/// Creates an instance of PetaPoco using the specified .
///
@@ -406,5 +440,7 @@ public static IDatabase Create(this IDatabaseBuildConfiguration source)
{
return new Database(source);
}
+
+ #endregion
}
}
diff --git a/PetaPoco/IAlterPoco.cs b/PetaPoco/IAlterPoco.cs
index cbdaa0b4..30240182 100644
--- a/PetaPoco/IAlterPoco.cs
+++ b/PetaPoco/IAlterPoco.cs
@@ -6,6 +6,16 @@ public interface IAlterPoco
{
#region Insert
+ ///
+ /// Performs an SQL Insert.
+ ///
+ ///
+ /// The name of the table, its primary key and whether it's an auto-allocated primary key are retrieved from the POCO's attributes
+ ///
+ /// A POCO object containing the column values to be inserted.
+ /// The auto allocated primary key of the new record, or for non-auto-increment tables.
+ object Insert(object poco);
+
///
/// Performs an SQL Insert.
///
@@ -36,16 +46,6 @@ public interface IAlterPoco
/// The auto allocated primary key of the new record, or for non-auto-increment tables.
object Insert(string tableName, string primaryKeyName, bool autoIncrement, object poco);
- ///
- /// Performs an SQL Insert.
- ///
- ///
- /// The name of the table, its primary key and whether it's an auto-allocated primary key are retrieved from the POCO's attributes
- ///
- /// A POCO object containing the column values to be inserted.
- /// The auto allocated primary key of the new record, or for non-auto-increment tables.
- object Insert(object poco);
-
#endregion
#region Update
@@ -53,96 +53,103 @@ public interface IAlterPoco
///
/// Performs an SQL update.
///
- /// The name of the table to update.
- /// The name of the primary key column of the table.
/// A POCO object containing the column values to be updated.
- /// The primary key of the record to be updated.
- /// The number of affected records.
- int Update(string tableName, string primaryKeyName, object poco, object primaryKeyValue);
+ /// The number of affected rows.
+ int Update(object poco);
///
/// Performs an SQL update.
///
- /// The name of the table to update.
- /// The name of the primary key column of the table.
/// A POCO object containing the column values to be updated.
- /// The primary key of the record to be updated.
/// The column names of the columns to be updated, or for all.
/// The number of affected rows.
- int Update(string tableName, string primaryKeyName, object poco, object primaryKeyValue, IEnumerable columns);
+ int Update(object poco, IEnumerable columns);
///
/// Performs an SQL update.
///
- /// The name of the table to update.
- /// The name of the primary key column of the table.
/// A POCO object containing the column values to be updated.
+ /// The primary key of the record to be updated.
/// The number of affected rows.
- int Update(string tableName, string primaryKeyName, object poco);
+ int Update(object poco, object primaryKeyValue);
///
/// Performs an SQL update.
///
- /// The name of the table to update.
- /// The name of the primary key column of the table.
/// A POCO object containing the column values to be updated.
+ /// The primary key of the record to be updated.
/// The column names of the columns to be updated, or for all.
/// The number of affected rows.
- int Update(string tableName, string primaryKeyName, object poco, IEnumerable columns);
+ int Update(object poco, object primaryKeyValue, IEnumerable columns);
///
/// Performs an SQL update.
///
+ /// The name of the table to update.
+ /// The name of the primary key column of the table.
/// A POCO object containing the column values to be updated.
- /// The column names of the columns to be updated, or for all.
/// The number of affected rows.
- int Update(object poco, IEnumerable columns);
+ int Update(string tableName, string primaryKeyName, object poco);
///
/// Performs an SQL update.
///
+ /// The name of the table to update.
+ /// The name of the primary key column of the table.
/// A POCO object containing the column values to be updated.
+ /// The column names of the columns to be updated, or for all.
/// The number of affected rows.
- int Update(object poco);
+ int Update(string tableName, string primaryKeyName, object poco, IEnumerable columns);
///
/// Performs an SQL update.
///
+ /// The name of the table to update.
+ /// The name of the primary key column of the table.
/// A POCO object containing the column values to be updated.
/// The primary key of the record to be updated.
- /// The number of affected rows.
- int Update(object poco, object primaryKeyValue);
+ /// The number of affected records.
+ int Update(string tableName, string primaryKeyName, object poco, object primaryKeyValue);
///
/// Performs an SQL update.
///
+ /// The name of the table to update.
+ /// The name of the primary key column of the table.
/// A POCO object containing the column values to be updated.
/// The primary key of the record to be updated.
/// The column names of the columns to be updated, or for all.
/// The number of affected rows.
- int Update(object poco, object primaryKeyValue, IEnumerable columns);
+ int Update(string tableName, string primaryKeyName, object poco, object primaryKeyValue, IEnumerable columns);
///
/// Performs an SQL update.
///
/// The POCO class whose attributes specify the name of the table to update.
- /// The SQL update and condition clause (everything after UPDATE tablename ).
- /// Arguments to any embedded parameters in the SQL.
+ /// An SQL builder object representing the SQL update and condition clause (everything after UPDATE tablename ).
/// The number of affected rows.
- int Update(string sql, params object[] args);
+ int Update(Sql sql);
///
/// Performs an SQL update.
///
/// The POCO class whose attributes specify the name of the table to update.
- /// An SQL builder object representing the SQL update and condition clause (everything after UPDATE tablename ).
+ /// The SQL update and condition clause (everything after UPDATE tablename ).
+ /// Arguments to any embedded parameters in the SQL.
/// The number of affected rows.
- int Update(Sql sql);
+ int Update(string sql, params object[] args);
#endregion
#region Delete
+ ///
+ /// Performs an SQL Delete.
+ ///
+ /// A POCO object specifying the table name and primary key value of the row to be deleted.
+ /// The number of rows affected.
+ int Delete(object poco);
+
///
/// Performs an SQL Delete.
///
@@ -162,13 +169,6 @@ public interface IAlterPoco
/// The number of rows affected.
int Delete(string tableName, string primaryKeyName, object poco, object primaryKeyValue);
- ///
- /// Performs an SQL Delete.
- ///
- /// A POCO object specifying the table name and primary key value of the row to be deleted.
- /// The number of rows affected.
- int Delete(object poco);
-
///
/// Performs an SQL Delete.
///
@@ -181,18 +181,18 @@ public interface IAlterPoco
/// Performs an SQL Delete.
///
/// The POCO class whose attributes specify the name of the table to delete from.
- /// The SQL condition clause identifying the row to delete (everything after DELETE FROM tablename ).
- /// Arguments to any embedded parameters in the SQL.
+ /// An SQL builder object representing the SQL condition clause identifying the row to delete (everything after DELETE FROM tablename ).
/// The number of affected rows.
- int Delete(string sql, params object[] args);
+ int Delete(Sql sql);
///
/// Performs an SQL Delete.
///
/// The POCO class whose attributes specify the name of the table to delete from.
- /// An SQL builder object representing the SQL condition clause identifying the row to delete (everything after DELETE FROM tablename ).
+ /// The SQL condition clause identifying the row to delete (everything after DELETE FROM tablename ).
+ /// Arguments to any embedded parameters in the SQL.
/// The number of affected rows.
- int Delete(Sql sql);
+ int Delete(string sql, params object[] args);
#endregion
@@ -204,10 +204,9 @@ public interface IAlterPoco
///
/// This method simply tests if the POCO's primary key column property has a non-default value.
///
- /// The name of the primary key column.
/// The object instance whose "newness" is to be tested.
/// if the POCO represents a record already in the database.
- bool IsNew(string primaryKeyName, object poco);
+ bool IsNew(object poco);
///
/// Checks if a poco represents a new row.
@@ -215,9 +214,10 @@ public interface IAlterPoco
///
/// This method simply tests if the POCO's primary key column property has a non-default value.
///
+ /// The name of the primary key column.
/// The object instance whose "newness" is to be tested.
/// if the POCO represents a record already in the database.
- bool IsNew(object poco);
+ bool IsNew(string primaryKeyName, object poco);
#endregion
@@ -226,16 +226,16 @@ public interface IAlterPoco
///
/// Saves a POCO by performing either an INSERT or UPDATE operation.
///
- /// The name of the table to be updated.
- /// The name of the primary key column.
/// The POCO object to be saved.
- void Save(string tableName, string primaryKeyName, object poco);
+ void Save(object poco);
///
/// Saves a POCO by performing either an INSERT or UPDATE operation.
///
+ /// The name of the table to be updated.
+ /// The name of the primary key column.
/// The POCO object to be saved.
- void Save(object poco);
+ void Save(string tableName, string primaryKeyName, object poco);
#endregion
}
diff --git a/PetaPoco/IAlterPocoAsync.cs b/PetaPoco/IAlterPocoAsync.cs
index 392df356..6e1f98c0 100644
--- a/PetaPoco/IAlterPocoAsync.cs
+++ b/PetaPoco/IAlterPocoAsync.cs
@@ -6,17 +6,17 @@ namespace PetaPoco
{
public interface IAlterPocoAsync
{
- #region Insert
+ #region InsertAsync
///
- /// Async version of .
+ /// Async version of .
///
- Task InsertAsync(string tableName, object poco);
+ Task InsertAsync(object poco);
///
/// Async version of .
///
- Task InsertAsync(CancellationToken cancellationToken, string tableName, object poco);
+ Task InsertAsync(string tableName, object poco);
///
/// Async version of .
@@ -24,88 +24,83 @@ public interface IAlterPocoAsync
Task InsertAsync(string tableName, string primaryKeyName, object poco);
///
- /// Async version of .
+ /// Async version of .
///
- Task InsertAsync(CancellationToken cancellationToken, string tableName, string primaryKeyName, object poco);
+ Task InsertAsync(string tableName, string primaryKeyName, bool autoIncrement, object poco);
///
- /// Async version of .
+ /// Async version of .
///
- Task InsertAsync(string tableName, string primaryKeyName, bool autoIncrement, object poco);
+ Task InsertAsync(CancellationToken cancellationToken, object poco);
///
- /// Async version of .
+ /// Async version of .
///
- Task InsertAsync(CancellationToken cancellationToken, string tableName, string primaryKeyName, bool autoIncrement, object poco);
+ Task InsertAsync(CancellationToken cancellationToken, string tableName, object poco);
///
- /// Async version of .
+ /// Async version of .
///
- Task InsertAsync(object poco);
+ Task InsertAsync(CancellationToken cancellationToken, string tableName, string primaryKeyName, object poco);
///
- /// Async version of .
+ /// Async version of .
///
- Task InsertAsync(CancellationToken cancellationToken, object poco);
+ Task InsertAsync(CancellationToken cancellationToken, string tableName, string primaryKeyName, bool autoIncrement, object poco);
#endregion
- #region Update
+ #region UpdateAsync
///
- /// Async version of .
+ /// Async version of .
///
- Task UpdateAsync(string tableName, string primaryKeyName, object poco, object primaryKeyValue);
+ Task UpdateAsync(object poco);
///
- /// Async version of .
+ /// Async version of .
///
- Task UpdateAsync(CancellationToken cancellationToken, string tableName, string primaryKeyName, object poco, object primaryKeyValue);
+ Task UpdateAsync(object poco, IEnumerable columns);
///
- /// Async version of .
+ /// Async version of .
///
- Task UpdateAsync(string tableName, string primaryKeyName, object poco, object primaryKeyValue, IEnumerable columns);
+ Task UpdateAsync(object poco, object primaryKeyValue);
///
- /// Async version of .
+ /// Async version of .
///
- Task UpdateAsync(CancellationToken cancellationToken, string tableName, string primaryKeyName, object poco, object primaryKeyValue, IEnumerable columns);
+ Task UpdateAsync(object poco, object primaryKeyValue, IEnumerable columns);
///
/// Async version of .
///
Task UpdateAsync(string tableName, string primaryKeyName, object poco);
- ///
- /// Async version of .
- ///
- Task UpdateAsync(CancellationToken cancellationToken, string tableName, string primaryKeyName, object poco);
-
///
/// Async version of .
///
Task UpdateAsync(string tableName, string primaryKeyName, object poco, IEnumerable columns);
///
- /// Async version of .
+ /// Async version of .
///
- Task UpdateAsync(CancellationToken cancellationToken, string tableName, string primaryKeyName, object poco, IEnumerable columns);
+ Task UpdateAsync(string tableName, string primaryKeyName, object poco, object primaryKeyValue);
///
- /// Async version of .
+ /// Async version of .
///
- Task UpdateAsync(object poco, IEnumerable columns);
+ Task UpdateAsync(string tableName, string primaryKeyName, object poco, object primaryKeyValue, IEnumerable columns);
///
- /// Async version of .
+ /// Async version of .
///
- Task UpdateAsync(CancellationToken cancellationToken, object poco, IEnumerable columns);
+ Task UpdateAsync(Sql sql);
///
- /// Async version of .
+ /// Async version of .
///
- Task UpdateAsync(object poco);
+ Task UpdateAsync(string sql, params object[] args);
///
/// Async version of .
@@ -113,9 +108,9 @@ public interface IAlterPocoAsync
Task UpdateAsync(CancellationToken cancellationToken, object poco);
///
- /// Async version of .
+ /// Async version of .
///
- Task UpdateAsync(object poco, object primaryKeyValue);
+ Task UpdateAsync(CancellationToken cancellationToken, object poco, IEnumerable columns);
///
/// Async version of .
@@ -125,46 +120,51 @@ public interface IAlterPocoAsync
///
/// Async version of .
///
- Task UpdateAsync(object poco, object primaryKeyValue, IEnumerable columns);
+ Task UpdateAsync(CancellationToken cancellationToken, object poco, object primaryKeyValue, IEnumerable columns);
///
- /// Async version of .
+ /// Async version of .
///
- Task UpdateAsync(CancellationToken cancellationToken, object poco, object primaryKeyValue, IEnumerable columns);
+ Task UpdateAsync(CancellationToken cancellationToken, string tableName, string primaryKeyName, object poco);
///
- /// Async version of .
+ /// Async version of .
///
- Task UpdateAsync(string sql, params object[] args);
+ Task UpdateAsync(CancellationToken cancellationToken, string tableName, string primaryKeyName, object poco, IEnumerable columns);
///
- /// Async version of .
+ /// Async version of .
///
- Task UpdateAsync(CancellationToken cancellationToken, string sql, params object[] args);
+ Task UpdateAsync(CancellationToken cancellationToken, string tableName, string primaryKeyName, object poco, object primaryKeyValue);
///
- /// Async version of .
+ /// Async version of .
///
- Task UpdateAsync(Sql sql);
+ Task UpdateAsync(CancellationToken cancellationToken, string tableName, string primaryKeyName, object poco, object primaryKeyValue, IEnumerable columns);
///
/// Async version of .
///
Task UpdateAsync(CancellationToken cancellationToken, Sql sql);
+ ///
+ /// Async version of .
+ ///
+ Task UpdateAsync(CancellationToken cancellationToken, string sql, params object[] args);
+
#endregion
- #region Delete
+ #region DeleteAsync
///
- /// Async version of .
+ /// Async version of .
///
- Task DeleteAsync(string tableName, string primaryKeyName, object poco);
+ Task DeleteAsync(object poco);
///
/// Async version of .
///
- Task DeleteAsync(CancellationToken cancellationToken, string tableName, string primaryKeyName, object poco);
+ Task DeleteAsync(string tableName, string primaryKeyName, object poco);
///
/// Async version of .
@@ -172,73 +172,73 @@ public interface IAlterPocoAsync
Task DeleteAsync(string tableName, string primaryKeyName, object poco, object primaryKeyValue);
///
- /// Async version of .
+ /// Async version of .
///
- Task DeleteAsync(CancellationToken cancellationToken, string tableName, string primaryKeyName, object poco, object primaryKeyValue);
+ Task DeleteAsync(object pocoOrPrimaryKey);
///
- /// Async version of .
+ /// Async version of .
///
- Task DeleteAsync(object poco);
+ Task DeleteAsync(Sql sql);
///
- /// Async version of .
+ /// Async version of .
///
- Task DeleteAsync(CancellationToken cancellationToken, object poco);
+ Task DeleteAsync(string sql, params object[] args);
///
- /// Async version of .
+ /// Async version of .
///
- Task DeleteAsync(object pocoOrPrimaryKey);
+ Task DeleteAsync(CancellationToken cancellationToken, object poco);
///
- /// Async version of .
+ /// Async version of .
///
- Task DeleteAsync(CancellationToken cancellationToken, object pocoOrPrimaryKey);
+ Task DeleteAsync(CancellationToken cancellationToken, string tableName, string primaryKeyName, object poco);
///
- /// Async version of .
+ /// Async version of .
///
- Task DeleteAsync(string sql, params object[] args);
+ Task DeleteAsync(CancellationToken cancellationToken, string tableName, string primaryKeyName, object poco, object primaryKeyValue);
///
- /// Async version of .
+ /// Async version of .
///
- Task DeleteAsync(CancellationToken cancellationToken, string sql, params object[] args);
+ Task DeleteAsync(CancellationToken cancellationToken, object pocoOrPrimaryKey);
///
/// Async version of .
///
- Task DeleteAsync(Sql sql);
+ Task DeleteAsync(CancellationToken cancellationToken, Sql sql);
///
- /// Async version of .
+ /// Async version of .
///
- Task DeleteAsync(CancellationToken cancellationToken, Sql sql);
+ Task DeleteAsync(CancellationToken cancellationToken, string sql, params object[] args);
#endregion
- #region Save
+ #region SaveAsync
///
- /// Async version of .
+ /// Async version of .
///
- Task SaveAsync(string tableName, string primaryKeyName, object poco);
+ Task SaveAsync(object poco);
///
/// Async version of .
///
- Task SaveAsync(CancellationToken cancellationToken, string tableName, string primaryKeyName, object poco);
+ Task SaveAsync(string tableName, string primaryKeyName, object poco);
///
/// Async version of .
///
- Task SaveAsync(object poco);
+ Task SaveAsync(CancellationToken cancellationToken, object poco);
///
- /// Async version of .
+ /// Async version of .
///
- Task SaveAsync(CancellationToken cancellationToken, object poco);
+ Task SaveAsync(CancellationToken cancellationToken, string tableName, string primaryKeyName, object poco);
#endregion
}
diff --git a/PetaPoco/IDatabase.cs b/PetaPoco/IDatabase.cs
index 01f8cb96..5d04de0b 100644
--- a/PetaPoco/IDatabase.cs
+++ b/PetaPoco/IDatabase.cs
@@ -139,6 +139,18 @@ public interface IDatabase : IDisposable, IQuery, IAlterPoco, IExecute, ITransac
///
void BeginTransaction();
+#if ASYNC
+ ///
+ /// Async version of .
+ ///
+ Task BeginTransactionAsync();
+
+ ///
+ /// Async version of .
+ ///
+ Task BeginTransactionAsync(CancellationToken cancellationToken);
+#endif
+
///
/// Aborts the entire outermost transaction scope.
///
@@ -177,31 +189,19 @@ public interface IDatabase : IDisposable, IQuery, IAlterPoco, IExecute, ITransac
///
event EventHandler CommandExecuted;
- ///
- /// Occurs when a database connection is about to be closed.
- ///
- event EventHandler ConnectionClosing;
-
///
/// Occurs when a database connection has been opened.
///
event EventHandler ConnectionOpened;
///
- /// Occurs when a database exception has been thrown.
- ///
- event EventHandler ExceptionThrown;
-
-#if ASYNC
- ///
- /// Async version of .
+ /// Occurs when a database connection is about to be closed.
///
- Task BeginTransactionAsync();
+ event EventHandler ConnectionClosing;
///
- /// Async version of .
+ /// Occurs when a database exception has been thrown.
///
- Task BeginTransactionAsync(CancellationToken cancellationToken);
-#endif
+ event EventHandler ExceptionThrown;
}
}
diff --git a/PetaPoco/IExecute.cs b/PetaPoco/IExecute.cs
index 17e3657b..9fe2154b 100644
--- a/PetaPoco/IExecute.cs
+++ b/PetaPoco/IExecute.cs
@@ -11,33 +11,33 @@ public interface IExecute
///
/// Executes a non-query command.
///
- /// The SQL statement to execute.
- /// Arguments to any embedded parameters in the SQL statement.
+ /// An Sql builder object representing the SQL statement and its arguments.
/// The number of rows affected.
- int Execute(string sql, params object[] args);
+ int Execute(Sql sql);
///
/// Executes a non-query command.
///
- /// An Sql builder object representing the SQL statement and its arguments.
+ /// The SQL statement to execute.
+ /// Arguments to any embedded parameters in the SQL statement.
/// The number of rows affected.
- int Execute(Sql sql);
+ int Execute(string sql, params object[] args);
///
/// Executes the query and returns the first column of the first row in the result set.
///
/// The type that the result value should be cast to.
- /// The SQL query to execute.
- /// Arguments to any embedded parameters in the SQL statement.
+ /// An Sql builder object representing the SQL query and its arguments.
/// The scalar value cast to .
- T ExecuteScalar(string sql, params object[] args);
+ T ExecuteScalar(Sql sql);
///
/// Executes the query and returns the first column of the first row in the result set.
///
/// The type that the result value should be cast to.
- /// An Sql builder object representing the SQL query and its arguments.
+ /// The SQL query to execute.
+ /// Arguments to any embedded parameters in the SQL statement.
/// The scalar value cast to .
- T ExecuteScalar(Sql sql);
+ T ExecuteScalar(string sql, params object[] args);
}
}
diff --git a/PetaPoco/IExecuteAsync.cs b/PetaPoco/IExecuteAsync.cs
index b82629e5..38e00178 100644
--- a/PetaPoco/IExecuteAsync.cs
+++ b/PetaPoco/IExecuteAsync.cs
@@ -12,53 +12,53 @@ namespace PetaPoco
///
public interface IExecuteAsync
{
+ ///
+ Task ExecuteAsync(Sql sql);
+
///
Task ExecuteAsync(string sql, params object[] args);
+ ///
+ Task ExecuteScalarAsync(Sql sql);
+
+ ///
+ Task ExecuteScalarAsync(string sql, params object[] args);
+
///
/// Asynchronously executes a non-query command with a cancellation token.
///
/// A cancellation token that can be used to cancel the operation.
- /// The SQL statement to execute.
- /// Arguments to any embedded parameters in the SQL statement.
+ /// An Sql builder object representing the SQL statement and its arguments.
/// A task that represents the asynchronous operation. The task result is the number of rows affected.
- Task ExecuteAsync(CancellationToken cancellationToken, string sql, params object[] args);
-
- ///
- Task ExecuteAsync(Sql sql);
+ Task ExecuteAsync(CancellationToken cancellationToken, Sql sql);
///
/// Asynchronously executes a non-query command with a cancellation token.
///
/// A cancellation token that can be used to cancel the operation.
- /// An Sql builder object representing the SQL statement and its arguments.
+ /// The SQL statement to execute.
+ /// Arguments to any embedded parameters in the SQL statement.
/// A task that represents the asynchronous operation. The task result is the number of rows affected.
- Task ExecuteAsync(CancellationToken cancellationToken, Sql sql);
-
- ///
- Task ExecuteScalarAsync(string sql, params object[] args);
+ Task ExecuteAsync(CancellationToken cancellationToken, string sql, params object[] args);
///
/// Asynchronously executes the query with a cancellation token and returns the first column of the first row in the result set.
///
/// The type that the result value should be cast to.
/// A cancellation token that can be used to cancel the operation.
- /// The SQL query to execute.
- /// Arguments to any embedded parameters in the SQL statement.
+ /// An Sql builder object representing the SQL query and its arguments.
/// A task that represents the asynchronous operation. The task result is the scalar value cast to .
- Task ExecuteScalarAsync(CancellationToken cancellationToken, string sql, params object[] args);
-
- ///
- Task ExecuteScalarAsync(Sql sql);
+ Task ExecuteScalarAsync(CancellationToken cancellationToken, Sql sql);
///
/// Asynchronously executes the query with a cancellation token and returns the first column of the first row in the result set.
///
/// The type that the result value should be cast to.
/// A cancellation token that can be used to cancel the operation.
- /// An Sql builder object representing the SQL query and its arguments.
+ /// The SQL query to execute.
+ /// Arguments to any embedded parameters in the SQL statement.
/// A task that represents the asynchronous operation. The task result is the scalar value cast to .
- Task ExecuteScalarAsync(CancellationToken cancellationToken, Sql sql);
+ Task ExecuteScalarAsync(CancellationToken cancellationToken, string sql, params object[] args);
}
#endif
}
diff --git a/PetaPoco/IQuery.cs b/PetaPoco/IQuery.cs
index 5829f74b..d2bd1a98 100644
--- a/PetaPoco/IQuery.cs
+++ b/PetaPoco/IQuery.cs
@@ -5,7 +5,7 @@ namespace PetaPoco
{
public interface IQuery
{
- #region Query
+ #region Query : Single-Poco
///
/// Streams the result of a select all query (SELECT *).
@@ -24,10 +24,9 @@ public interface IQuery
/// For some DB providers, care should be taken to not start a new Query before finishing with and disposing of the previous one. In cases where this is an issue, consider using Fetch, which returns the results as a List rather than an IEnumerable.
///
/// The Type representing a row in the result set.
- /// The SQL query.
- /// Arguments to any embedded parameters in the SQL statement.
+ /// An SQL builder object representing the base SQL query and its arguments.
/// An IEnumerable collection of POCOs.
- IEnumerable Query(string sql, params object[] args);
+ IEnumerable Query(Sql sql);
///
/// Runs an SQL query, returning the results as an IEnumerable collection.
@@ -36,21 +35,66 @@ public interface IQuery
/// For some DB providers, care should be taken to not start a new Query before finishing with and disposing of the previous one. In cases where this is an issue, consider using Fetch, which returns the results as a List rather than an IEnumerable.
///
/// The Type representing a row in the result set.
- /// An SQL builder object representing the base SQL query and its arguments.
+ /// The SQL query.
+ /// Arguments to any embedded parameters in the SQL statement.
/// An IEnumerable collection of POCOs.
- IEnumerable Query(Sql sql);
+ IEnumerable Query(string sql, params object[] args);
+
+ #endregion
+
+ #region Query : Multi-Poco
+
+ ///
+ /// Perform a multi-poco query.
+ ///
+ /// The first POCO type.
+ /// The second POCO type.
+ /// An SQL builder object representing the query and its arguments.
+ /// A collection of POCOs as an IEnumerable.
+ IEnumerable Query(Sql sql);
+
+ ///
+ /// Perform a multi-poco query.
+ ///
+ /// The first POCO type.
+ /// The second POCO type.
+ /// The third POCO type.
+ /// An SQL builder object representing the query and its arguments.
+ /// A collection of POCOs as an IEnumerable.
+ IEnumerable Query(Sql sql);
+
+ ///
+ /// Perform a multi-poco query.
+ ///
+ /// The first POCO type.
+ /// The second POCO type.
+ /// The third POCO type.
+ /// The fourth POCO type.
+ /// An SQL builder object representing the query and its arguments.
+ /// A collection of POCOs as an IEnumerable.
+ IEnumerable Query(Sql sql);
+
+ ///
+ /// Perform a multi-poco query.
+ ///
+ /// The first POCO type.
+ /// The second POCO type.
+ /// The third POCO type.
+ /// The fourth POCO type.
+ /// The fifth POCO type.
+ /// An SQL builder object representing the query and its arguments.
+ /// A collection of POCOs as an IEnumerable.
+ IEnumerable Query(Sql sql);
///
/// Perform a multi-poco query.
///
/// The first POCO type.
/// The second POCO type.
- /// The type of objects in the returned IEnumerable.
- /// A callback function to connect the POCO instances, or to automatically guess the relationships.
/// The SQL query to be executed.
/// Arguments to any embedded parameters in the SQL.
/// A collection of POCOs as an IEnumerable.
- IEnumerable Query(Func cb, string sql, params object[] args);
+ IEnumerable Query(string sql, params object[] args);
///
/// Perform a multi-poco query.
@@ -58,12 +102,10 @@ public interface IQuery
/// The first POCO type.
/// The second POCO type.
/// The third POCO type.
- /// The type of objects in the returned IEnumerable.
- /// A callback function to connect the POCO instances, or to automatically guess the relationships.
/// The SQL query to be executed.
/// Arguments to any embedded parameters in the SQL.
/// A collection of POCOs as an IEnumerable.
- IEnumerable Query(Func cb, string sql, params object[] args);
+ IEnumerable Query(string sql, params object[] args);
///
/// Perform a multi-poco query.
@@ -72,12 +114,10 @@ public interface IQuery
/// The second POCO type.
/// The third POCO type.
/// The fourth POCO type.
- /// The type of objects in the returned IEnumerable.
- /// A callback function to connect the POCO instances, or to automatically guess the relationships.
/// The SQL query to be executed.
/// Arguments to any embedded parameters in the SQL.
/// A collection of POCOs as an IEnumerable.
- IEnumerable Query(Func cb, string sql, params object[] args);
+ IEnumerable Query(string sql, params object[] args);
///
/// Perform a multi-poco query.
@@ -87,12 +127,10 @@ public interface IQuery
/// The third POCO type.
/// The fourth POCO type.
/// The fifth POCO type.
- /// The type of objects in the returned IEnumerable.
- /// A callback function to connect the POCO instances, or to automatically guess the relationships.
/// The SQL query to be executed.
/// Arguments to any embedded parameters in the SQL.
/// A collection of POCOs as an IEnumerable.
- IEnumerable Query(Func cb, string sql, params object[] args);
+ IEnumerable Query(string sql, params object[] args);
///
/// Perform a multi-poco query.
@@ -149,10 +187,12 @@ public interface IQuery
///
/// The first POCO type.
/// The second POCO type.
+ /// The type of objects in the returned IEnumerable.
+ /// A callback function to connect the POCO instances, or to automatically guess the relationships.
/// The SQL query to be executed.
/// Arguments to any embedded parameters in the SQL.
/// A collection of POCOs as an IEnumerable.
- IEnumerable Query(string sql, params object[] args);
+ IEnumerable Query(Func cb, string sql, params object[] args);
///
/// Perform a multi-poco query.
@@ -160,10 +200,12 @@ public interface IQuery
/// The first POCO type.
/// The second POCO type.
/// The third POCO type.
+ /// The type of objects in the returned IEnumerable.
+ /// A callback function to connect the POCO instances, or to automatically guess the relationships.
/// The SQL query to be executed.
/// Arguments to any embedded parameters in the SQL.
/// A collection of POCOs as an IEnumerable.
- IEnumerable Query(string sql, params object[] args);
+ IEnumerable Query(Func cb, string sql, params object[] args);
///
/// Perform a multi-poco query.
@@ -172,10 +214,12 @@ public interface IQuery
/// The second POCO type.
/// The third POCO type.
/// The fourth POCO type.
+ /// The type of objects in the returned IEnumerable.
+ /// A callback function to connect the POCO instances, or to automatically guess the relationships.
/// The SQL query to be executed.
/// Arguments to any embedded parameters in the SQL.
/// A collection of POCOs as an IEnumerable.
- IEnumerable Query(string sql, params object[] args);
+ IEnumerable Query(Func cb, string sql, params object[] args);
///
/// Perform a multi-poco query.
@@ -185,67 +229,46 @@ public interface IQuery
/// The third POCO type.
/// The fourth POCO type.
/// The fifth POCO type.
+ /// The type of objects in the returned IEnumerable.
+ /// A callback function to connect the POCO instances, or to automatically guess the relationships.
/// The SQL query to be executed.
/// Arguments to any embedded parameters in the SQL.
/// A collection of POCOs as an IEnumerable.
- IEnumerable Query(string sql, params object[] args);
+ IEnumerable Query(Func cb, string sql, params object[] args);
///
- /// Perform a multi-poco query.
+ /// Performs a multi-poco query.
///
- /// The first POCO type.
- /// The second POCO type.
- /// An SQL builder object representing the query and its arguments.
+ /// The type of objects in the returned IEnumerable.
+ /// An array of Types representing the POCO types of the returned result set.
+ /// A callback function to connect the POCO instances, or to automatically guess the relationships.
+ /// The SQL query to be executed.
+ /// Arguments to any embedded parameters in the SQL.
/// A collection of POCOs as an IEnumerable.
- IEnumerable Query(Sql sql);
+ IEnumerable Query(Type[] types, object cb, string sql, params object[] args);
- ///
- /// Perform a multi-poco query.
- ///
- /// The first POCO type.
- /// The second POCO type.
- /// The third POCO type.
- /// An SQL builder object representing the query and its arguments.
- /// A collection of POCOs as an IEnumerable.
- IEnumerable Query(Sql sql);
+ #endregion
- ///
- /// Perform a multi-poco query.
- ///
- /// The first POCO type.
- /// The second POCO type.
- /// The third POCO type.
- /// The fourth POCO type.
- /// An SQL builder object representing the query and its arguments.
- /// A collection of POCOs as an IEnumerable.
- IEnumerable Query(Sql sql);
+ #region QueryMultiple : Multi-POCO Result Set IGridReader
///
- /// Perform a multi-poco query.
+ /// Perform a multi-results set query.
///
- /// The first POCO type.
- /// The second POCO type.
- /// The third POCO type.
- /// The fourth POCO type.
- /// The fifth POCO type.
/// An SQL builder object representing the query and its arguments.
- /// A collection of POCOs as an IEnumerable.
- IEnumerable Query(Sql sql);
+ /// A GridReader to be queried.
+ IGridReader QueryMultiple(Sql sql);
///
- /// Performs a multi-poco query.
+ /// Perform a multi-results set query.
///
- /// The type of objects in the returned IEnumerable.
- /// An array of Types representing the POCO types of the returned result set.
- /// A callback function to connect the POCO instances, or to automatically guess the relationships.
/// The SQL query to be executed.
/// Arguments to any embedded parameters in the SQL.
- /// A collection of POCOs as an IEnumerable.
- IEnumerable Query(Type[] types, object cb, string sql, params object[] args);
+ /// A GridReader to be queried.
+ IGridReader QueryMultiple(string sql, params object[] args);
#endregion
- #region Fetch
+ #region Fetch : Single-Poco
///
/// Runs a SELECT * query and returns the result set as a typed list.
@@ -254,6 +277,14 @@ public interface IQuery
/// A List holding the results of the query.
List Fetch();
+ ///
+ /// Runs a query and returns the result set as a typed list.
+ ///
+ /// The Type representing a row in the result set.
+ /// An SQL builder object representing the query and its arguments.
+ /// A List holding the results of the query.
+ List Fetch(Sql sql);
+
///
/// Runs a query and returns the result set as a typed list.
///
@@ -263,64 +294,61 @@ public interface IQuery
/// A List holding the results of the query.
List Fetch(string sql, params object[] args);
+ #endregion
+
+ #region Fetch : Multi-Poco
+
///
- /// Runs a query and returns the result set as a typed list.
+ /// Perform a multi-poco fetch.
///
- /// The Type representing a row in the result set.
+ /// The first POCO type.
+ /// The second POCO type.
/// An SQL builder object representing the query and its arguments.
- /// A List holding the results of the query.
- List Fetch(Sql sql);
+ /// A collection of POCOs as a List.
+ List Fetch