Learn More





New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

DAL 2 - IRepository Interface

  • 4/7/2015
  • 1934


DAL 2 - IRepository Interface

Last updated 6 years ago

The IRepository<T> interface can be considered the core of the new DAL 2. While the Execute methods of the IDataContext interface provide a DAL + like API, the benefits of the new API are really found when using the repository. The Repository Pattern is a common design pattern in modern data access layers. Martin Fowler’s definition of the pattern is:

Mediates between the domain and data mapping layers using a collection-like interface for accessing domain objects.

The pattern at its simplest provides simple CRUD (Create, Retrieve, Update and Delete) methods. In the DotNetNuke implementation there are a few extra overloads to provide flexibility.

public interface IRepository<T> where T : class

void Delete(T item);

void Delete(string sqlCondition, params object[] args);

IEnumerable<T> Find(string sqlCondition, params object[] args);

IPagedList<T> Find(int pageIndex, int pageSize, string sqlCondition, params object[] args);

IEnumerable<T> Get();

IEnumerable<T> Get<TScopeType>(TScopeType scopeValue);

T GetById<TProperty>(TProperty id);

T GetById<TProperty, TScopeType>(TProperty id, TScopeType scopeValue);

IPagedList<T> GetPage(int pageIndex, int pageSize);

IPagedList<T> GetPage<TScopeType>(TScopeType scopeValue, int pageIndex, int pageSize);

void Insert(T item);

void Update(T item);

void Update(string sqlCondition, params object[] args);

Subscribe to DNN Digest

DNN Digest is our monthly email newsletter. It highlights news and content from around the DNN ecosystem, such as new modules and themes, messages from leadership, blog posts and notable tweets. Keep your finger on the pulse of the ecosystem by subscribing.  

What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out