Created
October 13, 2014 10:31
-
-
Save stevenh77/ef6d81d981ad180dace8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 AccountRepository : DataRepositoryBase<Account>, IAccountRepository | |
{ | |
protected override Account AddEntity(CarRentalContext entityContext, Account entity) | |
{ | |
return entityContext.AccountSet.Add(entity); | |
} | |
protected override Account UpdateEntity(CarRentalContext entityContext, Account entity) | |
{ | |
return (from e in entityContext.AccountSet | |
where e.AccountId == entity.AccountId | |
select e).FirstOrDefault(); | |
} | |
protected override IEnumerable<Account> GetEntities(CarRentalContext entityContext) | |
{ | |
return from e in entityContext.AccountSet | |
select e; | |
} | |
protected override Account GetEntity(CarRentalContext entityContext, int id) | |
{ | |
var query = (from e in entityContext.AccountSet | |
where e.AccountId == id | |
select e); | |
var results = query.FirstOrDefault(); | |
return results; | |
} | |
public Account GetByLogin(string login) | |
{ | |
using (CarRentalContext entityContext = new CarRentalContext()) | |
{ | |
return (from a in entityContext.AccountSet | |
where a.LoginEmail == login | |
select a).FirstOrDefault(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment