Last active
December 19, 2015 08:29
-
-
Save odytrice/5926037 to your computer and use it in GitHub Desktop.
Interface for the DataRepository
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// An Abstraction for a Generic DataAccess Repoository | |
/// </summary> | |
public interface IDataRepository | |
{ | |
/// <summary> | |
/// Get all Elements of Type T | |
/// </summary> | |
/// <typeparam name="T">Entity Type</typeparam> | |
/// <returns>DbSet of Entities</returns> | |
IQueryable<T> Get<T>() where T : class; | |
/// <summary> | |
/// | |
/// </summary> | |
/// <typeparam name="T"></typeparam> | |
/// <param name="includeProperties"></param> | |
/// <returns></returns> | |
IQueryable<T> Get<T>(params Expression<Func<T, object>>[] includeProperties) where T : class; | |
/// <summary> | |
/// Add an Entity to the Persistence Storage | |
/// </summary> | |
/// <typeparam name="T">Entity Type</typeparam> | |
/// <param name="item">Entity to be Added</param> | |
void Add<T>(T item) where T : class; | |
/// <summary> | |
/// Delete an Entity from the Persistence Storage | |
/// </summary> | |
/// <typeparam name="T">Entity Type</typeparam> | |
/// <param name="item">Entity to be Removed</param> | |
void Delete<T>(T item) where T : class; | |
/// <summary> | |
/// Get a Single Entity from the Persistence Storage using the Entities' ID | |
/// </summary> | |
/// <typeparam name="T">Entity Type</typeparam> | |
/// <param name="id">ID of the Entity</param> | |
/// <returns>Single Entity or Null</returns> | |
T GetByID<T>(int id) where T : class; | |
/// <summary> | |
/// Updates a Specific Entity to the Persistence Storage | |
/// </summary> | |
/// <typeparam name="T"></typeparam> | |
/// <param name="item"></param> | |
void Update<T>(T item) where T : class; | |
/// <summary> | |
/// Executes an Arbitrary SQL and returns Entities Instead | |
/// </summary> | |
/// <typeparam name="T">Return Type</typeparam> | |
/// <param name="sql">SQL Statement</param> | |
/// <returns>Enumerable of Entities</returns> | |
IEnumerable<T> Execute<T>(string sql); | |
/// <summary> | |
/// Executes a Stored Proceedure | |
/// </summary> | |
/// <typeparam name="T">Return Type</typeparam> | |
/// <param name="name">Name of Stored Procedure</param> | |
/// <param name="args">Any object whose properties are the parameters for the Proceedure</param> | |
/// <returns>Enumerable of Entities</returns> | |
IEnumerable<T> Execute<T>(string name, object args); | |
/// <summary> | |
/// Executes an Arbitrary SQL that does not need return entities.. Useful for CUD commands | |
/// </summary> | |
/// <param name="sql">SQL Statement</param> | |
/// <returns>An operation describing the status of the command</returns> | |
void Execute(string sql, object args); | |
/// <summary> | |
/// Executes an Arbitrary SQL that does not need return entities.. Useful for CUD commands | |
/// </summary> | |
/// <param name="sql">SQL Statement</param> | |
void Execute(string sql); | |
/// <summary> | |
/// Saves in Memory Changes to the Persistence Storage | |
/// </summary> | |
/// <returns>An operation describing the status of the command</returns> | |
Operation SaveChanges(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment