Skip to content

Instantly share code, notes, and snippets.

@GuyHarwood
Last active December 14, 2015 04:39
Show Gist options
  • Save GuyHarwood/5029946 to your computer and use it in GitHub Desktop.
Save GuyHarwood/5029946 to your computer and use it in GitHub Desktop.
I am sick of seeing code like this...
//the 'domain/service' layer...
public class ContactService
{
public ContactService(IContactRepository contactRepository)
{
_contactRepository = contactRepository;
}
public Contact GetContact(int id)
{
var contact = _contactRepository.FindById(id);
return contact;
}
}
//the 'data' layer...
public class ContactRepository : IContactRepository
{
public ContactRepository(DataContext db)
{
_db = db;
}
public Contact FindById(int id)
{
var qry = from c in _db.Contacts
where c.ContactId == id
&& c.IsDeleted == false
select c;
return qry.FirstOrDefault();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment