-
Notifications
You must be signed in to change notification settings - Fork 0
InitExtensions
Jacob Spitzer edited this page Aug 28, 2022
·
3 revisions
First create a class
[Table("Sample")]
public class Sample
{
public int Id { get; set; }
public string Field { get; set; }
}and then:
// Create a SqlConnection
var con = new SqlConnection("Server=YOUR.SERVER.COM; Database=DATABASE_NAME; User ID=USER_ID;Password=*******; Trusted_Connection=False; MultipleActiveResultSets=True");
// Get all records from the Sample Table
con.DbEc<Sample>().GetAll(); The start point of using this library.
Initialize a new DbEc<T> instanse, to query and/or modify the table with TQuery method extensions.
Or DbEcExtended<T> instanse, for more advanced options.
Initialize a new TQueryDatabase instanse, to modify the Database table defenitions with TQuery method extensions.
Or TQueryDatabaseExtended instanse, for more advanced options.
Inheritance System.Object 🡒 TQueryStartExtensions
| TQuery Methods | Description |
|---|---|
| TQuery<Table> | Basic TQuery extension methods for tables |
| TQuery<Table>(SqlConnection, SqlDialect) | Initializes a new instance of the DbEc<T>](DbEc_T_ 'DbEasyConnect.DbEc<T>') class when taken a class type that contains the [Table] attribute. |
| Execute() | Execute TQuery SQL command, and returns the number of rows affected. |
| ExecuteAsync() | Execute TQuery SQL command asynchronously using Task, and returns the number of rows affected. |
| Execute() | Execute TQuery SQL boolean command and returns true or false. |
| ExecuteAsync() | Execute TQuery SQL boolean command asynchronously using Task, and returns true or false. |
| AsEnumerable() | Executes a query, returning an IEnumerable object with the data typed as T. |
| ToList() | Executes TQuery SQL query, returning an List object with the data typed as T. |
| ToListAsync() | Executs TQuery SQL query asynchronously using Task, returning an List object with the data typed as T. |
| ToSqlString() | Returns the TQuery generated Sql command. To modify the Sql command manually, use the TQueryExtended method, and then use the ModifySqlString<Table>(DbEcExtended<Table>, string) method. |
| ToSqlString() | Returns the TQuery generated Sql command. To modify the Sql command manually, use the TQueryExtended method, and then use the ModifySqlString or ReplaceInSqlString method. |
| TQueryDb | TQuery extension methods for the database |
| TQueryDb<Table>(SqlConnection, SqlDialect) | Initializes a new instance of the TQueryDatabase class. |
| Execute() | Execute TQuery SQL command. |
| ExecuteAsync() | Execute TQuery SQL command asynchronously using Task. |
| TQueryExtended<Table> | Advanced TQuery extension methods for tables |
| TQueryExtended<Table>(SqlConnection, SqlDialect) | Initializes a new instance of the DbEcExtended<T> class when taken a class type that contains the [Table] attribute. |
| ModifySqlString<Table>(DbEcExtended<Table>, string) | Modifies manually the TQuery SQL command with any given string. |
| ReplaceInSqlString<Table>(DbEcExtended<Table>, string, string) | Replaces parts of the TQuery SQL command. Use this method to replace any part of the SQL string according to the Database language. |
| TQueryDbExtended | Advanced TQuery extension methods for the database |
| TQueryDbExtended<Table>(SqlConnection, SqlDialect) | Initializes a new instance of the TQueryDatabase class. |
| Execute() | Execute TQuery SQL command. |
| ExecuteAsync() | Execute TQuery SQL command asynchronously using Task. |