private static void Projections() { using var ctx = new SandboxContext(); ctx.Database.EnsureCreated(); var parents = ctx.Parents.Select(ParentShort.Projection).ToList(); var items = ctx.Items.Select(ItemProjection.Projection).ToList(); var testFrom = from x in ctx.Parents select x; }
private static void ContextTest() { using var ctx = new SandboxContext(); ctx.Database.EnsureCreated(); var parent = new Parent { ChildName = "Test Name", Items = new List <Item> { new Item { Name = "Item1" }, new Item { Name = "Item2" }, new Item { Name = "Item3" } } }; ctx.Parents.Add(parent); ctx.SaveChanges(); Console.WriteLine("Press any key to delete dependants..."); Console.ReadLine(); var firstItem = parent.Items.First(); parent.Items.Remove(firstItem); ctx.SaveChanges(); Console.WriteLine("Press any key to delete principal..."); Console.ReadLine(); ctx.Parents.Remove(parent); ctx.SaveChanges(); }