Exemple #1
0
        private static void InsertSamuris()
        {
            Samuri samuri = new Samuri {
                Name = "Frank"
            };

            using (SamuriDbContext context = new SamuriDbContext())
            {
                context.Samuris.Add(samuri);
                context.SaveChanges();
            }
        }
Exemple #2
0
        private static void RetrieveAndUpdateSamuri()
        {
            using (SamuriDbContext context = new SamuriDbContext())
            {
                Samuri samuri = context.Samuris.FirstOrDefault();

                if (samuri == null)
                {
                    return;
                }

                samuri.Name += "San";
                context.SaveChanges();
            }
        }
Exemple #3
0
        private static void InsertMultipleSamuris()
        {
            Samuri samuri1 = new Samuri {
                Name = "Peter"
            };
            Samuri samuri2 = new Samuri {
                Name = "Paul"
            };
            List <Samuri> samuriList = new List <Samuri> {
                samuri1, samuri2
            };

            using (SamuriDbContext context = new SamuriDbContext())
            {
                context.Samuris.AddRange(samuriList);
                context.SaveChanges();
            }
        }