Esempio n. 1
0
        private static void RetrieveDataWithFind()
        {
            int keyval = 4;

            using (NinjaContext context = new NinjaContext())
            {
                context.Database.Log = Console.WriteLine;
                Ninja ninja = context.Ninjas.Find(keyval);
                Console.WriteLine("After Find#1:" + ninja.Name);

                Ninja someNinja = context.Ninjas.Find(keyval);
                Console.WriteLine("After Find#2:" + someNinja.Name);
                ninja = null;
            }
        }
Esempio n. 2
0
        private static void SimpleNinjaGraphQuery()
        {
            using (NinjaContext context = new NinjaContext())
            {
                context.Database.Log = Console.WriteLine;

                //var ninjas = context.Ninjas.Include(n => n.EquipmentOwned)
                //    .FirstOrDefault(n => n.Name.StartsWith("Kacy"));

                Ninja ninja = context.Ninjas
                              .FirstOrDefault(n => n.Name.StartsWith("Kacy"));
                Console.WriteLine("Ninja Retrieved:" + ninja.Name);
                //context.Entry(ninja).Collection(n => n.EquipmentOwned).Load();
                Console.WriteLine("Ninja Equipment cout {0}", ninja.EquipmentOwned.Count());
            }
        }
Esempio n. 3
0
        private static void InsertNinja()
        {
            Ninja ninja = new Ninja
            {
                Name             = "Jassar",
                ServedInOniwaban = false,
                DateOfBirth      = new DateTime(1994, 12, 03),
                ClanId           = 1
            };

            using (NinjaContext context = new NinjaContext())
            {
                context.Database.Log = Console.WriteLine;
                context.Ninjas.Add(ninja);
                context.SaveChanges();
            }
        }