private static Person GetPersonByName(PersonContext ctx, string name) { return ctx .Persons .Include(p => p.MemberOf) .AsNoTracking() .First(p => p.Name == name); }
public static IEnumerable<Person> LoadPersons(IEnumerable<string> names) { using (var ctx = new PersonContext(ConnectionString)) { return ctx .Persons .Include(p => p.MemberOf) .Where(p => names.Contains(p.Name)) .ToList(); } }
public static void TestIdentityMap() { using (var ctx = new PersonContext(ConnectionString)) { var personA1 = GetPersonByName(ctx, "A"); personA1.MemberOf.AddAmount(100); var personA2 = GetPersonByName(ctx, "A"); var orgA = ctx .Orgs .ToList() .First(o => o.Name.StartsWith("OrgA")); var orgB = ctx .Orgs .ToList() .First(o => o.Name.StartsWith("OrgB")); } }