Add full Markdown documentation set
This commit is contained in:
65
docs/quick-start.md
Normal file
65
docs/quick-start.md
Normal file
@@ -0,0 +1,65 @@
|
||||
# Quick Start
|
||||
|
||||
## Install and Reference
|
||||
|
||||
Reference the `DynamORM` project or package from your application.
|
||||
|
||||
## Basic Setup
|
||||
|
||||
```csharp
|
||||
using System.Data.SQLite;
|
||||
using DynamORM;
|
||||
|
||||
var options =
|
||||
DynamicDatabaseOptions.SingleConnection |
|
||||
DynamicDatabaseOptions.SingleTransaction |
|
||||
DynamicDatabaseOptions.SupportLimitOffset |
|
||||
DynamicDatabaseOptions.SupportSchema;
|
||||
|
||||
using (var db = new DynamicDatabase(
|
||||
SQLiteFactory.Instance,
|
||||
"Data Source=app.db;",
|
||||
options))
|
||||
{
|
||||
db.DumpCommands = true;
|
||||
|
||||
var users = db.Table("users");
|
||||
var total = users.Count(columns: "id");
|
||||
var first = users.First(columns: "id,first,last");
|
||||
}
|
||||
```
|
||||
|
||||
This setup mirrors `DynamORM.Tests/TestsBase.cs`.
|
||||
|
||||
## First Query (Dynamic API)
|
||||
|
||||
```csharp
|
||||
using (var db = new DynamicDatabase(SQLiteFactory.Instance, "Data Source=app.db;", options))
|
||||
{
|
||||
var row = db.Table("users").Single(id: 19);
|
||||
Console.WriteLine(row.first);
|
||||
}
|
||||
```
|
||||
|
||||
## First Query (Fluent Builder API)
|
||||
|
||||
```csharp
|
||||
using (var db = new DynamicDatabase(SQLiteFactory.Instance, "Data Source=app.db;", options))
|
||||
using (var query = db.From("users").Where("id", 19).SelectColumn("first"))
|
||||
{
|
||||
var first = query.ScalarAs<string>();
|
||||
Console.WriteLine(first);
|
||||
}
|
||||
```
|
||||
|
||||
## Insert, Update, Delete
|
||||
|
||||
```csharp
|
||||
var table = db.Table("users");
|
||||
|
||||
table.Insert(code: "201", first: "Juri", last: "Gagarin");
|
||||
table.Update(values: new { first = "Yuri" }, where: new { code = "201" });
|
||||
table.Delete(code: "201");
|
||||
```
|
||||
|
||||
These forms are validated in `DynamORM.Tests/Modify/DynamicModificationTests.cs`.
|
||||
Reference in New Issue
Block a user