Class SQLiteContext
SQLite implementation of IDatabaseContext for use in Unity. Supports both persistent and in-memory databases depending on the platform.
public class SQLiteContext : IDatabaseContext
Inheritance
Implements
Constructors
SQLiteContext()
Initializes a new instance of the SQLiteContext class and establishes a connection to the SQLite database.
public SQLiteContext()
Methods
Create<T>(T)
Inserts a new item into the database.
public void Create<T>(T item)
Parameters
| Name | Type | Description |
|---|---|---|
item | T | The item to insert. |
Type Parameters
| Name | Type | Description |
|---|---|---|
T | The type of the item to insert. |
CreateOrUpdate<T>(T)
Inserts a new item or updates an existing one in the database.
public void CreateOrUpdate<T>(T item)
Parameters
| Name | Type | Description |
|---|---|---|
item | T | The item to insert or update. |
Type Parameters
| Name | Type | Description |
|---|---|---|
T | The type of the item to insert or update. |
Delete<T>(T)
Deletes the specified item from the database.
public void Delete<T>(T item)
Parameters
| Name | Type | Description |
|---|---|---|
item | T | The item to delete. |
Type Parameters
| Name | Type | Description |
|---|---|---|
T | The type of the item to delete. |
DeleteById<T, K>(K)
Deletes an item from the database using its primary key.
public void DeleteById<T, K>(K primaryKey)
Parameters
| Name | Type | Description |
|---|---|---|
primaryKey | K | The primary key of the item to delete. |
Type Parameters
| Name | Type | Description |
|---|---|---|
T | The type of the item to delete. | |
K | The type of the primary key. |
Read<T>(Expression<Func<T, bool>>)
Retrieves a single item from the database that matches the specified predicate.
public T Read<T>(Expression<Func<T, bool>> predicate) where T : new()
Parameters
| Name | Type | Description |
|---|---|---|
predicate | Expression<Func<T, bool>> | An expression used to filter the item. |
Returns
T — The item that matches the predicate, or null if no match is found.
Type Parameters
| Name | Type | Description |
|---|---|---|
T | The type of the item to read. |