Ejemplo n.º 1
0
 //
 // Summary:
 //     By default queries the table matching the class name
 //     -Table name can be overridden by adding an attribute on your class [Table("YourTableName")]
 //     conditions is an SQL where clause ex: "where name='bob'" or "where age>=@Age"
 //     - not required
 //     parameters is an anonymous type to pass in named parameter values: new { Age
 //     = 15 }
 //     Supports transaction and command timeout
 //     ///
 //
 // Parameters:
 //   connection:
 //
 //   conditions:
 //
 //   parameters:
 //
 //   transaction:
 //
 //   commandTimeout:
 //
 // Type parameters:
 //   T:
 //
 // Returns:
 //     Returns a count of records.
 public Task <int> RecordCountAsync(string conditions = "", object parameters = null, IDbTransaction transaction = null, int?commandTimeout = null)
 {
     return(MethodHelper.CatchFunction(Connection.RecordCountAsync <T>, conditions, parameters, transaction, commandTimeout));
 }
Ejemplo n.º 2
0
 //
 // Summary:
 //     By default queries the table matching the class name
 //     -Table name can be overridden by adding an attribute on your class [Table("YourTableName")]
 //     Returns a number of records entity by a single id from table T
 //     Supports transaction and command timeout
 //     whereConditions is an anonymous type to filter the results ex: new {Category
 //     = 1, SubCategory=2}
 //
 // Parameters:
 //   connection:
 //
 //   whereConditions:
 //
 //   transaction:
 //
 //   commandTimeout:
 //
 // Type parameters:
 //   T:
 //
 // Returns:
 //     Returns a count of records.
 public Task <int> RecordCountAsync(object whereConditions, IDbTransaction transaction = null, int?commandTimeout = null)
 {
     return(MethodHelper.CatchFunction(Connection.RecordCountAsync <T>, whereConditions, transaction, commandTimeout));
 }
Ejemplo n.º 3
0
 //
 // Summary:
 //     Inserts a row into the database, using ONLY the properties defined by T
 //     By default inserts into the table matching the class name
 //     -Table name can be overridden by adding an attribute on your class [Table("YourTableName")]
 //     Insert filters out Id column and any columns with the [Key] attribute
 //     Properties marked with attribute [Editable(false)] and complex types are ignored
 //     Supports transaction and command timeout
 //     Returns the ID (primary key) of the newly inserted record if it is identity using
 //     the defined type, otherwise null
 //
 // Parameters:
 //   connection:
 //
 //   entityToInsert:
 //
 //   transaction:
 //
 //   commandTimeout:
 //
 // Returns:
 //     The ID (primary key) of the newly inserted record if it is identity using the
 //     defined type, otherwise null
 public TKey Insert <TKey>(T entityToInsert, IDbTransaction transaction = null, int?commandTimeout = null)
 {
     return(MethodHelper.CatchFunction(Connection.Insert <TKey, T>, entityToInsert, transaction, commandTimeout));
 }
Ejemplo n.º 4
0
 //
 // Summary:
 //     Inserts a row into the database asynchronously
 //     By default inserts into the table matching the class name
 //     -Table name can be overridden by adding an attribute on your class [Table("YourTableName")]
 //     Insert filters out Id column and any columns with the [Key] attribute
 //     Properties marked with attribute [Editable(false)] and complex types are ignored
 //     Supports transaction and command timeout
 //     Returns the ID (primary key) of the newly inserted record if it is identity using
 //     the int? type, otherwise null
 //
 // Parameters:
 //   connection:
 //
 //   entityToInsert:
 //
 //   transaction:
 //
 //   commandTimeout:
 //
 // Returns:
 //     The ID (primary key) of the newly inserted record if it is identity using the
 //     int? type, otherwise null
 public Task <int?> InsertAsync(T entityToInsert, IDbTransaction transaction = null, int?commandTimeout = null)
 {
     return(MethodHelper.CatchFunction(Connection.InsertAsync, entityToInsert, transaction, commandTimeout));
 }
Ejemplo n.º 5
0
 //
 // Summary:
 //     Execute parameterized SQL.
 //
 // Parameters:
 //   cnn:
 //     The connection to query on.
 //
 //   sql:
 //     The SQL to execute for this query.
 //
 //   param:
 //     The parameters to use for this query.
 //
 //   transaction:
 //     The transaction to use for this query.
 //
 //   commandTimeout:
 //     Number of seconds before command execution timeout.
 //
 //   commandType:
 //     Is it a stored proc or a batch?
 //
 // Returns:
 //     The number of rows affected.
 public int Execute(string sql, object param = null, IDbTransaction transaction = null, int?commandTimeout = null, CommandType?commandType = null)
 {
     return(MethodHelper.CatchFunction(Connection.Execute, sql, param, transaction, commandTimeout, commandType));
 }
Ejemplo n.º 6
0
 //
 // Summary:
 //     Deletes a list of records in the database
 //     By default deletes records in the table matching the class name
 //     -Table name can be overridden by adding an attribute on your class [Table("YourTableName")]
 //     Deletes records where that match the where clause
 //     whereConditions is an anonymous type to filter the results ex: new {Category
 //     = 1, SubCategory=2}
 //     The number of records affected
 //     Supports transaction and command timeout
 //
 // Parameters:
 //   connection:
 //
 //   whereConditions:
 //
 //   transaction:
 //
 //   commandTimeout:
 //
 // Type parameters:
 //   T:
 //
 // Returns:
 //     The number of records affected
 public int DeleteList <T>(object whereConditions, IDbTransaction transaction = null, int?commandTimeout = null)
 {
     return(MethodHelper.CatchFunction(Connection.DeleteList <T>, whereConditions, transaction, commandTimeout));
 }
Ejemplo n.º 7
0
 //
 // Summary:
 //     By default queries the table matching the class name
 //     -Table name can be overridden by adding an attribute on your class [Table("YourTableName")]
 //     conditions is an SQL where clause and/or order by clause ex: "where name='bob'"
 //     or "where age>=@Age"
 //     parameters is an anonymous type to pass in named parameter values: new { Age
 //     = 15 }
 //     Supports transaction and command timeout
 //     Returns a list of entities that match where conditions
 //
 // Parameters:
 //   connection:
 //
 //   conditions:
 //
 //   parameters:
 //
 //   transaction:
 //
 //   commandTimeout:
 //
 // Type parameters:
 //   T:
 //
 // Returns:
 //     Gets a list of entities with optional SQL where conditions
 public Task <IEnumerable <T> > GetListAsync(string conditions, object parameters = null, IDbTransaction transaction = null, int?commandTimeout = null)
 {
     return(MethodHelper.CatchFunction(Connection.GetListAsync <T>, conditions, parameters, transaction, commandTimeout));
 }
Ejemplo n.º 8
0
 //
 // Summary:
 //     Updates a record or records in the database asynchronously
 //     By default updates records in the table matching the class name
 //     -Table name can be overridden by adding an attribute on your class [Table("YourTableName")]
 //     Updates records where the Id property and properties with the [Key] attribute
 //     match those in the database.
 //     Properties marked with attribute [Editable(false)] and complex types are ignored
 //     Supports transaction and command timeout
 //     Returns number of rows affected
 //
 // Parameters:
 //   connection:
 //
 //   entityToUpdate:
 //
 //   transaction:
 //
 //   commandTimeout:
 //
 // Returns:
 //     The number of affected records
 public async Task <int> UpdateAsync(T entityToUpdate, IDbTransaction transaction = null, int?commandTimeout = null, CancellationToken?token = null)
 {
     return(await MethodHelper.CatchFunction(Connection.UpdateAsync, entityToUpdate, transaction, commandTimeout, token));
 }
Ejemplo n.º 9
0
 //
 // Summary:
 //     By default queries the table matching the class name
 //     -Table name can be overridden by adding an attribute on your class [Table("YourTableName")]
 //     whereConditions is an anonymous type to filter the results ex: new {Category
 //     = 1, SubCategory=2}
 //     Supports transaction and command timeout
 //     Returns a list of entities that match where conditions
 //
 // Parameters:
 //   connection:
 //
 //   whereConditions:
 //
 //   transaction:
 //
 //   commandTimeout:
 //
 // Type parameters:
 //   T:
 //
 // Returns:
 //     Gets a list of entities with optional exact match where conditions
 public IList <T> GetList(object whereConditions, IDbTransaction transaction = null, int?commandTimeout = null)
 {
     return(MethodHelper.CatchFunction(Connection.GetList <T>, whereConditions, transaction, commandTimeout).ToList());
 }
Ejemplo n.º 10
0
 //
 // Summary:
 //     By default queries the table matching the class name asynchronously
 //     -Table name can be overridden by adding an attribute on your class [Table("YourTableName")]
 //     Returns a list of all entities
 //
 // Parameters:
 //   connection:
 //
 // Type parameters:
 //   T:
 //
 // Returns:
 //     Gets a list of all entities
 public Task <IEnumerable <T> > GetListAsync()
 {
     return(MethodHelper.CatchFunction(Connection.GetListAsync <T>));
 }
Ejemplo n.º 11
0
 //
 // Summary:
 //     By default queries the table matching the class name
 //     -Table name can be overridden by adding an attribute on your class [Table("YourTableName")]
 //     conditions is an SQL where clause and/or order by clause ex: "where name='bob'"
 //     or "where age>=@Age"
 //     parameters is an anonymous type to pass in named parameter values: new { Age
 //     = 15 }
 //     Supports transaction and command timeout
 //     Returns a list of entities that match where conditions
 //
 // Parameters:
 //   connection:
 //
 //   conditions:
 //
 //   parameters:
 //
 //   transaction:
 //
 //   commandTimeout:
 //
 // Type parameters:
 //   T:
 //
 // Returns:
 //     Gets a list of entities with optional SQL where conditions
 public IList <T> GetList(string conditions, object parameters = null, IDbTransaction transaction = null, int?commandTimeout = null)
 {
     return(MethodHelper.CatchFunction(Connection.GetList <T>, conditions, parameters, transaction, commandTimeout).ToList());
 }
Ejemplo n.º 12
0
 //
 // Summary:
 //     By default queries the table matching the class name
 //     -Table name can be overridden by adding an attribute on your class [Table("YourTableName")]
 //     Returns a list of all entities
 //
 // Parameters:
 //   connection:
 //
 // Type parameters:
 //   T:
 //
 // Returns:
 //     Gets a list of all entities
 public IEnumerable <T> GetList()
 {
     return(MethodHelper.CatchFunction(Connection.GetList <T>));
 }
Ejemplo n.º 13
0
 //
 // Summary:
 //     By default queries the table matching the class name asynchronously
 //     -Table name can be overridden by adding an attribute on your class [Table("YourTableName")]
 //     By default filters on the Id column
 //     -Id column name can be overridden by adding an attribute on your primary key
 //     property [Key]
 //     Supports transaction and command timeout
 //     Returns a single entity by a single id from table T
 //
 // Parameters:
 //   connection:
 //
 //   id:
 //
 //   transaction:
 //
 //   commandTimeout:
 //
 // Type parameters:
 //   T:
 //
 // Returns:
 //     Returns a single entity by a single id from table T.
 public Task <T> GetAsync(object id, IDbTransaction transaction = null, int?commandTimeout = null)
 {
     return(MethodHelper.CatchFunction(Connection.GetAsync <T>, id, transaction, commandTimeout));
 }
Ejemplo n.º 14
0
 //
 // Summary:
 //     Updates a record or records in the database with only the properties of TEntity
 //     By default updates records in the table matching the class name
 //     -Table name can be overridden by adding an attribute on your class [Table("YourTableName")]
 //     Updates records where the Id property and properties with the [Key] attribute
 //     match those in the database.
 //     Properties marked with attribute [Editable(false)] and complex types are ignored
 //     Supports transaction and command timeout
 //     Returns number of rows affected
 //
 // Parameters:
 //   connection:
 //
 //   entityToUpdate:
 //
 //   transaction:
 //
 //   commandTimeout:
 //
 // Returns:
 //     The number of affected records
 public int Update(T entityToUpdate, IDbTransaction transaction = null, int?commandTimeout = null)
 {
     return(MethodHelper.CatchFunction(Connection.Update, entityToUpdate, transaction, commandTimeout));
 }
Ejemplo n.º 15
0
 //
 // Summary:
 //     By default queries the table matching the class name asynchronously
 //     -Table name can be overridden by adding an attribute on your class [Table("YourTableName")]
 //     whereConditions is an anonymous type to filter the results ex: new {Category
 //     = 1, SubCategory=2}
 //     Supports transaction and command timeout
 //     Returns a list of entities that match where conditions
 //
 // Parameters:
 //   connection:
 //
 //   whereConditions:
 //
 //   transaction:
 //
 //   commandTimeout:
 //
 // Type parameters:
 //   T:
 //
 // Returns:
 //     Gets a list of entities with optional exact match where conditions
 public Task <IEnumerable <T> > GetListAsync <T>(object whereConditions, IDbTransaction transaction = null, int?commandTimeout = null)
 {
     return(MethodHelper.CatchFunction(Connection.GetListAsync <T>, whereConditions, transaction, commandTimeout));
 }
Ejemplo n.º 16
0
 //
 // Summary:
 //     Deletes a record or records in the database by ID
 //     By default deletes records in the table matching the class name
 //     -Table name can be overridden by adding an attribute on your class [Table("YourTableName")]
 //     Deletes records where the Id property and properties with the [Key] attribute
 //     match those in the database
 //     The number of records affected
 //     Supports transaction and command timeout
 //
 // Parameters:
 //   connection:
 //
 //   id:
 //
 //   transaction:
 //
 //   commandTimeout:
 //
 // Type parameters:
 //   T:
 //
 // Returns:
 //     The number of records affected
 public int Delete(object id, IDbTransaction transaction = null, int?commandTimeout = null)
 {
     return(MethodHelper.CatchFunction(Connection.Delete, id, transaction, commandTimeout));
 }
Ejemplo n.º 17
0
 //
 // Summary:
 //     By default queries the table matching the class name
 //     -Table name can be overridden by adding an attribute on your class [Table("YourTableName")]
 //     conditions is an SQL where clause ex: "where name='bob'" or "where age>=@Age"
 //     - not required
 //     orderby is a column or list of columns to order by ex: "lastname, age desc" -
 //     not required - default is by primary key
 //     parameters is an anonymous type to pass in named parameter values: new { Age
 //     = 15 }
 //     Supports transaction and command timeout
 //     Returns a list of entities that match where conditions
 //
 // Parameters:
 //   connection:
 //
 //   pageNumber:
 //
 //   rowsPerPage:
 //
 //   conditions:
 //
 //   orderby:
 //
 //   parameters:
 //
 //   transaction:
 //
 //   commandTimeout:
 //
 // Type parameters:
 //   T:
 //
 // Returns:
 //     Gets a paged list of entities with optional exact match where conditions
 public IList <T> GetListPaged(int pageNumber, int rowsPerPage, string conditions, string orderby, object parameters = null, IDbTransaction transaction = null, int?commandTimeout = null)
 {
     return(MethodHelper.CatchFunction(Connection.GetListPaged <T>, pageNumber, rowsPerPage, conditions, orderby, parameters, transaction, commandTimeout).ToList());
 }
Ejemplo n.º 18
0
 //
 // Summary:
 //     Return a sequence of dynamic objects with properties matching the columns.
 //
 // Parameters:
 //   cnn:
 //     The connection to query on.
 //
 //   sql:
 //     The SQL to execute for the query.
 //
 //   param:
 //     The parameters to pass, if any.
 //
 //   transaction:
 //     The transaction to use, if any.
 //
 //   buffered:
 //     Whether to buffer the results in memory.
 //
 //   commandTimeout:
 //     The command timeout (in seconds).
 //
 //   commandType:
 //     The type of command to execute.
 //
 // Remarks:
 //     Note: each row can be accessed via "dynamic", or by casting to an IDictionary<string,object>
 public IEnumerable <T> Query(string sql, object param = null, IDbTransaction transaction = null, bool buffered = true, int?commandTimeout = null, CommandType?commandType = null)
 {
     return(MethodHelper.CatchFunction(Connection.Query <T>, sql, param, transaction, buffered, commandTimeout, commandType));
 }
Ejemplo n.º 19
0
 //
 // Summary:
 //     By default queries the table matching the class name
 //     -Table name can be overridden by adding an attribute on your class [Table("YourTableName")]
 //     conditions is an SQL where clause ex: "where name='bob'" or "where age>=@Age"
 //     - not required
 //     orderby is a column or list of columns to order by ex: "lastname, age desc" -
 //     not required - default is by primary key
 //     parameters is an anonymous type to pass in named parameter values: new { Age
 //     = 15 }
 //     Returns a list of entities that match where conditions
 //
 // Parameters:
 //   connection:
 //
 //   pageNumber:
 //
 //   rowsPerPage:
 //
 //   conditions:
 //
 //   orderby:
 //
 //   parameters:
 //
 //   transaction:
 //
 //   commandTimeout:
 //
 // Type parameters:
 //   T:
 //
 // Returns:
 //     Gets a list of entities with optional exact match where conditions
 public Task <IEnumerable <T> > GetListPagedAsync(int pageNumber, int rowsPerPage, string conditions, string orderby, object parameters = null, IDbTransaction transaction = null, int?commandTimeout = null)
 {
     return(MethodHelper.CatchFunction(Connection.GetListPagedAsync <T>, pageNumber, rowsPerPage, conditions, orderby, parameters, transaction, commandTimeout));
 }
Ejemplo n.º 20
0
 //
 // Summary:
 //     Execute parameterized SQL.
 //
 // Parameters:
 //   cnn:
 //     The connection to execute on.
 //
 //   command:
 //     The command to execute on this connection.
 //
 // Returns:
 //     The number of rows affected.
 public int Execute(CommandDefinition command)
 {
     return(MethodHelper.CatchFunction(Connection.Execute, command));
 }
Ejemplo n.º 21
0
 //
 // Summary:
 //     Deletes a record or records in the database that match the object passed in asynchronously
 //     -By default deletes records in the table matching the class name
 //     Table name can be overridden by adding an attribute on your class [Table("YourTableName")]
 //     Supports transaction and command timeout
 //     Returns the number of records affected
 //
 // Parameters:
 //   connection:
 //
 //   entityToDelete:
 //
 //   transaction:
 //
 //   commandTimeout:
 //
 // Type parameters:
 //   T:
 //
 // Returns:
 //     The number of records affected
 public Task <int> DeleteAsync(T entityToDelete, IDbTransaction transaction = null, int?commandTimeout = null)
 {
     return(MethodHelper.CatchFunction(Connection.DeleteAsync, entityToDelete, transaction, commandTimeout));
 }