示例#1
0
文件: Hudba.cs 项目: jurajblaha/Hudba
        public static bool InsertIntoDB(List <SongItem> hits)
        {
            try
            {
                HudbaEntities entities = new HudbaEntities();
                foreach (SongItem hit in hits)
                {
                    Song song = new Song();
                    song.Artist = hit.artist;
                    song.Id     = hit.id;
                    song.Lyrics = hit.lyrics;
                    song.Title  = hit.title;

                    entities.Songs.Add(song);;
                }

                entities.SaveChanges();

                return(true);
            }
            catch
            {
                return(false);
            }
        }
示例#2
0
文件: Hudba.cs 项目: jurajblaha/Hudba
        public static bool DeleteDBtable()
        {
            HudbaEntities entities = new HudbaEntities();

            entities.Database.ExecuteSqlCommand("Delete FROM Songs");

            entities.SaveChanges();

            return(true);
        }