DAL 2 - IRepository Interface

Return to previous page

  • 4/7/2015
  • 1070 Views

Comments

1070 Views

DAL 2 - IRepository Interface

Last updated 4 years ago

Comments

Common

(Enter the content of this article below)

Advanced

 
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.  


Copyright 2017 by DNN Corp Terms of Use Privacy
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out