Skip to content

Instantly share code, notes, and snippets.

@ashutoshraina
ashutoshraina / EFRepository.cs
Created February 2, 2013 11:47
EFRepository.cs
using System;
using System.Data.Entity;
using System.Linq;
namespace EFRepository.Infrastructure
{
/// <summary>
/// A EFRepository represents the repository for performing operations on the
/// Entity using the EntityFramework.
/// </summary>
@ashutoshraina
ashutoshraina / UnitOfWorkException.cs
Created February 2, 2013 11:46
UnitOfWorkException
using System;
namespace EFRepository.Infrastructure
{
[Serializable]
public class UnitOfWorkException : Exception
{
public override string Message
{
get
@ashutoshraina
ashutoshraina / IUnitOfWork.cs
Created February 2, 2013 11:46
IUnitOfWork
using System;
namespace EFRepository.Infrastructure
{
/// <summary>
/// The Interface for implementing a UnitOfWork in the Repository
/// </summary>
public interface IUnitOfWork : IDisposable
{
void Commit();
@ashutoshraina
ashutoshraina / IRepository.cs
Created February 2, 2013 11:45
IRepository
using System;
using System.Linq;
namespace EFRepository.Infrastructure
{
/// <summary>
/// Generic interface for the Repository.
/// </summary>
/// <typeparam name="T">EntityType T</typeparam>
public interface IRepository<T>
@ashutoshraina
ashutoshraina / EFUnitOfWork.cs
Created February 2, 2013 11:45
EFUnitOfWork
using System;
using System.Data.Entity;
namespace EFRepository.Infrastructure
{
/// <summary>
/// Represents an IUnitOfWork for Entity Framework
/// </summary>
public class EFUnitOfWork : IUnitOfWork
{
@ashutoshraina
ashutoshraina / RepositoryPattern.cs
Created November 30, 2012 12:12
EF Code First Repository Pattern
public interface IRepository<T> where T: class
{
void Add( T Entity);
void Delete( T Entity);
void Update ( T Entity);
IQueryable<T> GetAll<T>();
//some more methods
}
public interface IDatabaseFactory : IDisposable