Created
July 15, 2015 00:31
-
-
Save codebeaulieu/610c09e67b5c1c4343f4 to your computer and use it in GitHub Desktop.
my repository
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
public class BlogEngineRepository<T> : IRepository<T> where T : class | |
{ | |
protected DbSet<T> DbSet; | |
public BlogEngineRepository(DbContext dataContext) | |
{ | |
DbSet = dataContext.Set<T>(); | |
} | |
#region IRepository<T> Members | |
public void Insert(T entity) | |
{ | |
DbSet.Add(entity); | |
} | |
public void Delete(T entity) | |
{ | |
DbSet.Remove(entity); | |
} | |
public IQueryable<T> SearchFor(Expression<Func<T, bool>> predicate) | |
{ | |
return DbSet.Where(predicate); | |
} | |
public IQueryable<T> GetAll() | |
{ | |
return DbSet; | |
} | |
public T GetById(int id) | |
{ | |
return DbSet.Find(id); | |
} | |
#endregion | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment