Helper library for managing and querying SQL databases.
Used for holding the SQL connections.
var conn = new SqlConn(...);
Used for holding the SQL query string and parameters.
var query = new SqlQuery("SELECT * FROM [Users] WHERE [Id] = @Id").AddParameter("Id", "123");
Use this for excecuting SQL queries. This is a static class.
ExecuteNonQuery | Excecute a query that don't return anything. | SqlEngine.ExecuteNonQuery(query, conn) |
ExecuteReaderSingleSet | Excecute a query that returns a single dataset. | SqlEngine.ExecuteReaderSingleSet(query, conn) |
ExecuteReader | Excecute a query that returns multiple data sets. | SqlEngine.ExecuteReader(query, conn) |
CreateLocalDbIfDontExist | Creates a LocalDb. | SqlEngine.CreateLocalDbIfDontExist("C:\\Temp\\LocalDbs\\", "TestDb1") |
You can use the SqlTable and SqlColumn to create sql tables. There are some helper methods in the SqlFac to create a table based on a C# type.
var conn = new SqlConn(...); var table = SqlFac.Table<AccountEntity>(); SqlEngine.ExecuteNonQuery(table.ToCreateTableIfNotExistQuery(), conn);
var conn = new SqlConn(...); var table = SqlFac.Table<AccountEntity>(); SqlEngine.ExecuteNonQuery(table.ToDropAllDataQuery(), conn);
var conn = new SqlConn(...); var table = SqlFac.Table<AccountEntity>(); SqlEngine.ExecuteNonQuery(table.ToDropTableQuery(), conn);