Interface IDbSet<T>
An IDbSet represents the collection of all entities in the context, or that can be queried from the database, of a given type. DbSet is a concrete implementation of IDbSet.
Namespace: Kros.KORM.Query
Assembly: Kros.KORM.dll
Syntax
public interface IDbSet<T> : IEnumerable<T>, IEnumerable
Type Parameters
| Name | Description |
|---|---|
| T | The type that defines the set. |
Properties
AddedItems
List of items in Added state.
Declaration
IEnumerable<T> AddedItems { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<T> |
DeletedItems
List of items in Deleted state.
Declaration
IEnumerable<T> DeletedItems { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<T> |
EditedItems
List of items in Edited state.
Declaration
IEnumerable<T> EditedItems { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<T> |
Methods
Add(T)
Adds the item to the context underlying the set in the Added state such that it will be inserted into the database when CommitChanges is called.
Declaration
void Add(T entity)
Parameters
| Type | Name | Description |
|---|---|---|
| T | entity | The item to add. |
Add(IEnumerable<T>)
Adds the items to the context underlying the set in the Added state such that it will be inserted into the database when CommitChanges is called.
Declaration
void Add(IEnumerable<T> entities)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<T> | entities | The items to add. |
BulkInsert()
Bulk inserts pending added items.
Declaration
void BulkInsert()
Examples
var people = database.Query<Person>().AsDbSet();
foreach (var person in dataForImport)
{
people.Add(person);
}
people.BulkInsert();
BulkInsert(IEnumerable<T>)
Bulk inserts items.
Declaration
void BulkInsert(IEnumerable<T> items)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<T> | items | The items to insert. |
BulkInsertAsync()
Asynchronously bulk inserts pending added items.
Declaration
Task BulkInsertAsync()
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task | A task that represents the asynchronous bulk insert operation. |
BulkInsertAsync(IEnumerable<T>)
Asynchronously bulk inserts items.
Declaration
Task BulkInsertAsync(IEnumerable<T> items)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<T> | items | The items to insert. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task | A task that represents the asynchronous bulk insert operation. |
BulkUpdate()
Bulk updates pending edited items.
Declaration
void BulkUpdate()
Examples
var people = database.Query<Person>().AsDbSet();
foreach (var person in dataForUpdate)
{
people.Edit(person);
}
people.BulkUpdate();
BulkUpdate(Action<IDbConnection, IDbTransaction, String>)
Bulk updates pending edited items with specific action.
Declaration
void BulkUpdate(Action<IDbConnection, IDbTransaction, string> tempTableAction)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Action<System.Data.IDbConnection, System.Data.IDbTransaction, System.String> | tempTableAction | The action execute on temp table (modify data in temp table). |
BulkUpdate(IEnumerable<T>)
Bulk updates items.
Declaration
void BulkUpdate(IEnumerable<T> items)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<T> | items | The items to update. |
BulkUpdate(IEnumerable<T>, Action<IDbConnection, IDbTransaction, String>)
Bulk updates items with specific action.
Declaration
void BulkUpdate(IEnumerable<T> items, Action<IDbConnection, IDbTransaction, string> tempTableAction)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<T> | items | The items to update. |
| System.Action<System.Data.IDbConnection, System.Data.IDbTransaction, System.String> | tempTableAction | The action execute on temp table (modify data in temp table). |
BulkUpdateAsync()
Asynchronously bulk updates pending edited items.
Declaration
Task BulkUpdateAsync()
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task | A task that represents the asynchronous bulk update operation. |
BulkUpdateAsync(Action<IDbConnection, IDbTransaction, String>)
Asyncronousky bulk updates pending edited items with specific action.
Declaration
Task BulkUpdateAsync(Action<IDbConnection, IDbTransaction, string> tempTableAction)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Action<System.Data.IDbConnection, System.Data.IDbTransaction, System.String> | tempTableAction | The action execute on temp table (modify data in temp table). |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task | A task that represents the asynchronous bulk update operation. |
BulkUpdateAsync(IEnumerable<T>)
Asyncronously bulk updates items.
Declaration
Task BulkUpdateAsync(IEnumerable<T> items)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<T> | items | The items to update. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task | A task that represents the asynchronous bulk update operation. |
BulkUpdateAsync(IEnumerable<T>, Action<IDbConnection, IDbTransaction, String>)
Asynchronously bulk updates items with specific action.
Declaration
Task BulkUpdateAsync(IEnumerable<T> items, Action<IDbConnection, IDbTransaction, string> tempTableAction)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<T> | items | The items to update. |
| System.Action<System.Data.IDbConnection, System.Data.IDbTransaction, System.String> | tempTableAction | The action execute on temp table (modify data in temp table). |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task | A task that represents the asynchronous bulk update operation. |
Clear()
Rolls back all pending changes.
Declaration
void Clear()
CommitChanges()
Commits all pending changes to the database.
Declaration
void CommitChanges()
CommitChangesAsync()
Asynchronously commits all pending changes to the database.
Declaration
Task CommitChangesAsync()
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task | A task that represents the asynchronous save operation. |
Delete(T)
Marks the item as Deleted such that it will be deleted from the database when CommitChanges is called.
Declaration
void Delete(T entity)
Parameters
| Type | Name | Description |
|---|---|---|
| T | entity | The item to delete. |
Delete(IEnumerable<T>)
Marks the items as Deleted such that it will be deleted from the database when CommitChanges is called.
Declaration
void Delete(IEnumerable<T> entities)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<T> | entities | The items to delete. |
Edit(T)
Marks the item as Edited such that it will be updated in the database when CommitChanges is called.
Declaration
void Edit(T entity)
Parameters
| Type | Name | Description |
|---|---|---|
| T | entity | The item to edit. |
Edit(IEnumerable<T>)
Marks the items as Edited such that it will be updated in the database when CommitChanges is called.
Declaration
void Edit(IEnumerable<T> entities)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<T> | entities | The items to edit. |