@@ -14,7 +14,7 @@ For now there's no Nuget version, so you have to download/clone and build the cu
14
14
* SQL Server
15
15
* Oracle DB
16
16
* Postgres
17
- * MariaDB (through MySql , full support)
17
+ * MariaDB (through MySQL , full support)
18
18
* MySQL (partial - no index support - planned for full release)
19
19
20
20
Each database has its own project. You can only add what you'll use.
@@ -36,7 +36,7 @@ class User
36
36
37
37
using (var db = new Database .Database (new SqliteDatabase (), " Data Source=:memory:" ))
38
38
{
39
- db .CreateTableIfNotExists <User >();
39
+ db .CreateTable <User >();
40
40
41
41
db .Insert (new User { Id = 1 , Name = " Test User" });
42
42
@@ -249,23 +249,28 @@ db.DropForeignKeyIfExists<User>("FK_User_Address");
249
249
For automatic generation and Id usage, the following attributes can be used to decorate your properties.
250
250
251
251
``` csharp
252
- [Table (" USER" )]
252
+ [Table (" USER" )] // explicit table name
253
253
class User
254
254
{
255
+ // set as primary key, with the column name, and with AutoIncrement
255
256
[Column (isPrimaryKey : true , columnName : " User_ID" ), Identity ]
256
257
public int Id { get ; set ; }
257
258
259
+ // create an index when creating the table
258
260
[Index ]
259
261
public string Login { get ; set ; }
260
262
261
263
public string Name { get ; set ; }
262
264
265
+ // set as nullable
263
266
[Column (isRequired : false )]
264
267
public DateTime InsertDate { get ; set ; }
265
268
269
+ // ignore the field for db
266
270
[Ignore ]
267
271
public float Number { get ; set ; }
268
272
273
+ // create a foreign key to Address with the name provided
269
274
[Reference (typeof (Address ), " FK_User_Address" )]
270
275
public int AddressId { get ; set ; }
271
276
}
0 commit comments