示例#1
0
        private static void SeedGenres(ApplicationDbContext context)
        {
            var noGenre = new Models.Genre
            {
                Id   = "none",
                Name = "None"
            };

            context.Genres.AddOrUpdate(
                noGenre,
                new Models.Genre
            {
                Id   = "action",
                Name = "Action"
            }
                );

            context.Movies
            .Where(movie => movie.Genre == null)
            .ToList()
            .ForEach(movie => movie.Genre = noGenre);

            context.SaveChanges();
        }
示例#2
0
文件: Song.cs 项目: nataliena/CSharp
 public Song(string title, int length, Genre genre)
 {
     this.Title  = title;
     this.Length = length;
     this.Genre  = genre;
 }