Created
April 18, 2013 02:10
-
-
Save dfbaskin/5409444 to your computer and use it in GitHub Desktop.
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 ExampleDataRepository | |
{ | |
public IEnumerable<Person> GetSomePeople() | |
{ | |
using (var ctx = new ExampleDbContext()) | |
{ | |
return ctx.People.AsNoTracking().Take(30).ToList(); | |
} | |
} | |
public Person GetPerson(int personId) | |
{ | |
using (var ctx = new ExampleDbContext()) | |
{ | |
return | |
ctx | |
.People | |
.Include(p => p.EmailAddresses) | |
.Include(p => p.PostalAddresses) | |
.Include(p => p.PhoneNumbers) | |
.AsNoTracking() | |
.SingleOrDefault(p => p.PersonId == personId); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment