Interface IRepository<T>
Namespace: DotNetNuke.Data
Assembly: DotNetNuke.dll
Syntax
public interface IRepository<T>
where T : class
Type Parameters
Name | Description |
---|---|
T |
Methods
| Improve this Doc View SourceDelete(T)
Delete an Item from the repository.
Declaration
void Delete(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to be deleted. |
Delete(String, Object[])
Delete items from the repository based on a sql Condition.
Declaration
void Delete(string sqlCondition, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
System.String | sqlCondition | The sql condition e.g. "WHERE ArticleId = {0}". |
System.Object[] | args | A collection of arguments to be mapped to the tokens in the sqlCondition. |
Find(Int32, Int32, String, Object[])
Find a GetPage of items from the repository based on a sql condition.
Declaration
IPagedList<T> Find(int pageIndex, int pageSize, string sqlCondition, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pageIndex | The page Index to fetch. |
System.Int32 | pageSize | The size of the page to fetch. |
System.String | sqlCondition | The sql condition e.g. "WHERE ArticleId = @0". |
System.Object[] | args | A collection of arguments to be mapped to the tokens in the sqlCondition. |
Returns
Type | Description |
---|---|
IPagedList<T> | A list of items. |
Remarks
Find supports both full SQL statements such as "SELECT * FROM table WHERE ..." as well as a SQL condition like "WHERE ...".
Find(String, Object[])
Find items from the repository based on a sql condition.
Declaration
IEnumerable<T> Find(string sqlCondition, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
System.String | sqlCondition | The sql condition e.g. "WHERE ArticleId = @0". |
System.Object[] | args | A collection of arguments to be mapped to the tokens in the sqlCondition. |
Returns
Type | Description |
---|---|
IEnumerable<T> | A list of items. |
Remarks
Find supports both full SQL statements such as "SELECT * FROM table WHERE ..." as well as a SQL condition like "WHERE ...".
Examples
Find("where ArticleId = @0 and UserId = @1", articleId, userId).
| Improve this Doc View SourceGet()
Returns all the items in the repository as an enumerable list.
Declaration
IEnumerable<T> Get()
Returns
Type | Description |
---|---|
IEnumerable<T> | The list of items. |
Get<TScopeType>(TScopeType)
Returns an enumerable list of items filtered by scope.
Declaration
IEnumerable<T> Get<TScopeType>(TScopeType scopeValue)
Parameters
Type | Name | Description |
---|---|---|
TScopeType | scopeValue | The value of the scope to filter by. |
Returns
Type | Description |
---|---|
IEnumerable<T> | The list of items. |
Type Parameters
Name | Description |
---|---|
TScopeType | The type of the scope field. |
Remarks
This overload should be used to get a list of items for a specific module instance or for a specific portal dependening on how the items in the repository are scoped.
GetById<TProperty>(TProperty)
Get an individual item based on the items Id field.
Declaration
T GetById<TProperty>(TProperty id)
Parameters
Type | Name | Description |
---|---|---|
TProperty | id | The value of the Id field. |
Returns
Type | Description |
---|---|
T | An item. |
Type Parameters
Name | Description |
---|---|
TProperty | The type of the Id field. |
GetById<TProperty, TScopeType>(TProperty, TScopeType)
Get an individual item based on the items Id field.
Declaration
T GetById<TProperty, TScopeType>(TProperty id, TScopeType scopeValue)
Parameters
Type | Name | Description |
---|---|---|
TProperty | id | The value of the Id field. |
TScopeType | scopeValue | The value of the scope to filter by. |
Returns
Type | Description |
---|---|
T | An item. |
Type Parameters
Name | Description |
---|---|
TProperty | The type of the Id field. |
TScopeType | The type of the scope field. |
Remarks
This overload should be used to get an item for a specific module instance or for a specific portal dependening on how the items in the repository are scoped. This will allow the relevant cache to be searched first.
GetPage(Int32, Int32)
Returns a page of items in the repository as a paged list.
Declaration
IPagedList<T> GetPage(int pageIndex, int pageSize)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pageIndex | The page Index to fetch. |
System.Int32 | pageSize | The size of the page to fetch. |
Returns
Type | Description |
---|---|
IPagedList<T> | The list of items. |
GetPage<TScopeType>(TScopeType, Int32, Int32)
Returns a page of items in the repository as a paged list filtered by scope.
Declaration
IPagedList<T> GetPage<TScopeType>(TScopeType scopeValue, int pageIndex, int pageSize)
Parameters
Type | Name | Description |
---|---|---|
TScopeType | scopeValue | The value of the scope to filter by. |
System.Int32 | pageIndex | The page Index to fetch. |
System.Int32 | pageSize | The size of the page to fetch. |
Returns
Type | Description |
---|---|
IPagedList<T> | The list of items. |
Type Parameters
Name | Description |
---|---|
TScopeType | The type of the scope field. |
Remarks
This overload should be used to get a list of items for a specific module instance or for a specific portal dependening on how the items in the repository are scoped.
Insert(T)
Inserts an Item into the repository.
Declaration
void Insert(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to be inserted. |
Update(T)
Updates an Item in the repository.
Declaration
void Update(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to be updated. |
Update(String, Object[])
Update items in the repository based on a sql Condition.
Declaration
void Update(string sqlCondition, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
System.String | sqlCondition | The sql condition e.g. "SET ArticelName = @1 WHERE ArticleId = @0". |
System.Object[] | args | A collection of arguments to be mapped to the tokens in the sqlCondition. |
Examples
Update("SET Age=@1, Name=@2 WHERE ID=@0", 1, 21, "scooby").