Skip to content
This repository was archived by the owner on Apr 15, 2025. It is now read-only.

Commit 4bbf063

Browse files
committed
2 parents 1487a30 + b89a293 commit 4bbf063

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

‎README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ For now there's no Nuget version, so you have to download/clone and build the cu
1414
* SQL Server
1515
* Oracle DB
1616
* Postgres
17-
* MariaDB (through MySql, full support)
17+
* MariaDB (through MySQL, full support)
1818
* MySQL (partial - no index support - planned for full release)
1919

2020
Each database has its own project. You can only add what you'll use.
@@ -36,7 +36,7 @@ class User
3636

3737
using (var db = new Database.Database(new SqliteDatabase(), "Data Source=:memory:"))
3838
{
39-
db.CreateTableIfNotExists<User>();
39+
db.CreateTable<User>();
4040

4141
db.Insert(new User { Id = 1, Name = "Test User" });
4242

@@ -249,23 +249,28 @@ db.DropForeignKeyIfExists<User>("FK_User_Address");
249249
For automatic generation and Id usage, the following attributes can be used to decorate your properties.
250250

251251
```csharp
252-
[Table("USER")]
252+
[Table("USER")] // explicit table name
253253
class User
254254
{
255+
// set as primary key, with the column name, and with AutoIncrement
255256
[Column(isPrimaryKey: true, columnName: "User_ID"), Identity]
256257
public int Id { get; set; }
257258

259+
// create an index when creating the table
258260
[Index]
259261
public string Login { get; set; }
260262

261263
public string Name { get; set; }
262264

265+
// set as nullable
263266
[Column(isRequired: false)]
264267
public DateTime InsertDate { get; set; }
265268

269+
// ignore the field for db
266270
[Ignore]
267271
public float Number { get; set; }
268272

273+
// create a foreign key to Address with the name provided
269274
[Reference(typeof(Address), "FK_User_Address")]
270275
public int AddressId { get; set; }
271276
}

0 commit comments

Comments
 (0)