コード例 #1
0
 public void CreateAAuthor(string firstName, string lastName)
 {
     using (var db = new PlayContext())
     {
         db.Add(new Author
         {
             FirstName = firstName,
             LastName  = lastName
         });
         db.SaveChanges();
     }
 }
コード例 #2
0
 public void CreateATheatre(string name, string location, int capacity)
 {
     using (var db = new PlayContext())
     {
         db.Add(new Theatre
         {
             Name     = name,
             Location = location,
             Capacity = capacity
         });
         db.SaveChanges();
     }
 }
コード例 #3
0
        public void CreateAPlay(string title, string bio, string genre, object author, object theatre)
        {
            int?theatreObjId = null;

            if (theatre != null)
            {
                theatreObjId = ((Theatre)theatre).TheatreId;
            }
            ;

            using (var db = new PlayContext())
            {
                db.Add(new Play
                {
                    Title     = title,
                    Bio       = bio,
                    Genre     = genre,
                    AuthorId  = ((Author)author).AuthorId,
                    TheatreId = theatreObjId
                });
                db.SaveChanges();
            }
        }