Class RepositoryBase<T>
Implements
Namespace: DotNetNuke.Data
Assembly: DotNetNuke.dll
Syntax
public abstract class RepositoryBase<T> : object, IRepository<T> where T : class
Type Parameters
Name | Description |
---|---|
T |
Constructors
| Improve this Doc View SourceRepositoryBase()
Initializes a new instance of the RepositoryBase<T> class.
Declaration
protected RepositoryBase()
Properties
| Improve this Doc View SourceCacheArgs
Declaration
protected CacheItemArgs CacheArgs { get; }
Property Value
Type | Description |
---|---|
CacheItemArgs |
IsCacheable
Declaration
protected bool IsCacheable { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsScoped
Declaration
protected bool IsScoped { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Scope
Declaration
protected string Scope { get; }
Property Value
Type | Description |
---|---|
System.String |
Methods
| Improve this Doc View SourceCompareTo<TProperty>(TProperty, TProperty)
Declaration
protected int CompareTo<TProperty>(TProperty first, TProperty second)
Parameters
Type | Name | Description |
---|---|---|
TProperty | first | |
TProperty | second |
Returns
Type | Description |
---|---|
System.Int32 |
Type Parameters
Name | Description |
---|---|
TProperty |
Delete(T)
Delete an Item from the repository.
Declaration
public 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
public abstract 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. |
DeleteInternal(T)
Declaration
protected abstract void DeleteInternal(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item |
Find(Int32, Int32, String, Object[])
Find a GetPage of items from the repository based on a sql condition.
Declaration
public abstract 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
public abstract 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 ...".
Get()
Returns all the items in the repository as an enumerable list.
Declaration
public 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
public 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
public 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
public 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.
GetByIdInternal(Object)
Declaration
protected abstract T GetByIdInternal(object id)
Parameters
Type | Name | Description |
---|---|---|
System.Object | id |
Returns
Type | Description |
---|---|
T |
GetByScopeInternal(Object)
Declaration
protected abstract IEnumerable<T> GetByScopeInternal(object propertyValue)
Parameters
Type | Name | Description |
---|---|---|
System.Object | propertyValue |
Returns
Type | Description |
---|---|
IEnumerable<T> |
GetInternal()
Declaration
protected abstract IEnumerable<T> GetInternal()
Returns
Type | Description |
---|---|
IEnumerable<T> |
GetPage(Int32, Int32)
Returns a page of items in the repository as a paged list.
Declaration
public 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
public 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.
GetPageByScopeInternal(Object, Int32, Int32)
Declaration
protected abstract IPagedList<T> GetPageByScopeInternal(object propertyValue, int pageIndex, int pageSize)
Parameters
Type | Name | Description |
---|---|---|
System.Object | propertyValue | |
System.Int32 | pageIndex | |
System.Int32 | pageSize |
Returns
Type | Description |
---|---|
IPagedList<T> |
GetPageInternal(Int32, Int32)
Declaration
protected abstract IPagedList<T> GetPageInternal(int pageIndex, int pageSize)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pageIndex | |
System.Int32 | pageSize |
Returns
Type | Description |
---|---|
IPagedList<T> |
GetPrimaryKey<TProperty>(T)
Declaration
protected TProperty GetPrimaryKey<TProperty>(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item |
Returns
Type | Description |
---|---|
TProperty |
Type Parameters
Name | Description |
---|---|
TProperty |
GetPropertyValue<TProperty>(T, String)
Declaration
protected TProperty GetPropertyValue<TProperty>(T item, string propertyName)
Parameters
Type | Name | Description |
---|---|---|
T | item | |
System.String | propertyName |
Returns
Type | Description |
---|---|
TProperty |
Type Parameters
Name | Description |
---|---|
TProperty |
GetScopeValue<TProperty>(T)
Declaration
protected TProperty GetScopeValue<TProperty>(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item |
Returns
Type | Description |
---|---|
TProperty |
Type Parameters
Name | Description |
---|---|
TProperty |
Initialize(String, Int32, CacheItemPriority, String)
Declaration
public void Initialize(string cacheKey, int cacheTimeOut = 20, CacheItemPriority cachePriority = null, string scope = "")
Parameters
Type | Name | Description |
---|---|---|
System.String | cacheKey | |
System.Int32 | cacheTimeOut | |
CacheItemPriority | cachePriority | |
System.String | scope |
Insert(T)
Inserts an Item into the repository.
Declaration
public void Insert(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to be inserted. |
InsertInternal(T)
Declaration
protected abstract void InsertInternal(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item |
Update(T)
Updates an Item in the repository.
Declaration
public 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
public abstract 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. |
UpdateInternal(T)
Declaration
protected abstract void UpdateInternal(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item |