SqlExecutor Class
.NET Standard 2.x | Current Version (1.0.1)
SqlExecutor is a set of database manipulation interfaces that have encapsulated the core components of ADO.NET. Using SqlExecutor you can directly run dynamic SQL statements, perform SqlBuilder functions, and do model queries.
Namespace: SnapObjects.Data
Assembly: SnapObjects.Data.dll
Syntax
public class SqlExecutor : ISqlExecutor;
Constructors
Name | Description |
---|---|
SqlExecutor(DataContext context) | Initializes a new instance of the SqlExecutor class. |
Properties
Name | Return Type | Description |
---|---|---|
DataContext | DataContext | Gets the DataContext object. |
Method
Name | Return Type | Description |
---|---|---|
Execute(string sqlText, params object[] parameters) | int | Executes the SQL statements like UPDATE, INSERT, DELETE etc. |
ExecuteProcedure(string sqlText, params object[] parameters) | int | Executes a stored procedure. |
Scalar<TValue>(string sqlText, params object[] parameters) | TValue | Executes the SQL SELECT statement and returns the first column of the first row in the result set. |
Scalar<TValue>(ISqlQueryBuilder sqlQueryBuilder, params object[] parameters) | TValue | Executes the SQL SELECT statement created by an ISqlQueryBuilder object and returns the first column of the first row in the result set. |
Select<TModel>(string sqlText, params object[] parameters) | IList<TModel> | Executes the SQL SELECT statement and returns an IList<TModel> object. |
Select<TModel>(ISqlQueryBuilder queryBuilder, params object[] parameters) | IList<TModel> | Executes the SQL SELECT statement generated by an ISqlQueryBuilder object and returns an IList<TModel> object which contains the result set. |
SelectLazy<TModel>(params object[] parameters) | IEnumerable<TModel> | Executes the SQL SELECT statement and returns an IEnumerable <TModel> object that can be used to load the result set lazily. |
SelectLazy<TModel>(ISqlQueryBuilder queryBuilder, params object[] parameters) | IEnumerable<TModel> | Executes the SQL SELECT statement generated by an ISqlQueryBuilder object and returns an IEnumerable <TModel> object that can be used to load the result set lazily. |
SelectOne<TModel>(string sqlText, params object[] parameters) | TModel | Executes the SQL SELECT statement and returns the first row in the result set. |
SelectOne<TModel>(ISqlQueryBuilder queryBuilder, params object[] parameters) | TModel | Executes the SQL SELECT statement generated by an ISqlQueryBuilder object and returns the first row in the result set. |
SelectProcedure<TModel>(string sqlText, params object[] parameters) | IList<TModel> | Executes a SQL stored procedure and returns an IList<TModel> object which contains the result set. |
Remarks
SqlExecutor is a set of database manipulation interfaces that have encapsulated the core components of ADO.NET. Using SqlExecutor you can directly run dynamic SQL statements, perform SqlBuilder functions, and do model queries.
1. supports raw SQL as well as automatic SQL generation.
2. supports lazy loading of data to prevent unnecessary performance bottlenecks.
3. can bind result-sets to POCO or dynamic models.