Ejemplo n.º 1
0
        private static void UpdateOneArtist()
        {
            using (var context = new ChinookContext())
            {
                var police = context.Artists.Single(a => a.Name == "The Police");
                police.Name = "Police, The";

                var avril = context.Artists.Single(a => a.Name == "Avril Lavigne");
                context.Artists.Remove(avril);

                context.SaveChanges();
            }
        }
Ejemplo n.º 2
0
 private static void AddOneArtist()
 {
     using (var context = new ChinookContext())
     {
         context.Artists.Add(
             new Artist
             {
                 Name = "Anberlin",
                 Albums =
     {
         new Album { Title = "Cities" },
         new Album { Title = "New Surrender" }
     }
             });
         context.SaveChanges();
     }
 }
Ejemplo n.º 3
0
        private static void DumpAllArtists()
        {
            using (var context = new ChinookContext())
            {
                var artists = from a in context.Artists
                              where a.Name.StartsWith("A")
                              orderby a.Name
                              select a;

                int count = 0;
                foreach (var artist in artists)
                {
                    Console.WriteLine(artist.Name);
                    int cnt = artist.Albums.Count;
                    count++;
                }
                Console.WriteLine(count);
            }
        }
Ejemplo n.º 4
0
 public AlbumRepository(ChinookContext context)
 {
     _context = context;
 }
Ejemplo n.º 5
0
 public EfDeletePlaylistCommand(ChinookContext context) : base(context)
 {
 }
 public AlbumsController(ChinookContext context)
 {
     _context = context;
 }
 public TracksController(ChinookContext context)
 {
     _context = context;
 }
 public ArtistRepository(ChinookContext context)
 {
     _context = context;
 }
Ejemplo n.º 9
0
        public List <TrackList> List_TracksForPlaylistSelection(string tracksBy, int argId)
        {
            using (var context = new ChinookContext())
            {
                List <TrackList> results = null;

                switch (tracksBy)
                {
                case "Artist":
                {
                    results = (from x in context.Tracks
                               orderby x.Name
                               where x.Album.ArtistId == argId
                               select new TrackList
                        {
                            TrackID = x.TrackId,
                            Name = x.Name,
                            Title = x.Album.Title,
                            MediaName = x.MediaType.Name,
                            GenreName = x.Genre.Name,
                            Composer = x.Composer,
                            Milliseconds = x.Milliseconds,
                            Bytes = x.Bytes,
                            UnitPrice = x.UnitPrice
                        }).ToList();

                    break;
                }

                case "MediaType":
                {
                    results = (from x in context.Tracks
                               orderby x.Name
                               where x.MediaType.MediaTypeId == argId
                               select new TrackList
                        {
                            TrackID = x.TrackId,
                            Name = x.Name,
                            Title = x.Album.Title,
                            MediaName = x.MediaType.Name,
                            GenreName = x.Genre.Name,
                            Composer = x.Composer,
                            Milliseconds = x.Milliseconds,
                            Bytes = x.Bytes,
                            UnitPrice = x.UnitPrice
                        }).ToList();
                    break;
                }

                case "Genre":
                {
                    results = (from x in context.Tracks
                               orderby x.Name
                               where x.Genre.GenreId == argId
                               select new TrackList
                        {
                            TrackID = x.TrackId,
                            Name = x.Name,
                            Title = x.Album.Title,
                            MediaName = x.MediaType.Name,
                            GenreName = x.Genre.Name,
                            Composer = x.Composer,
                            Milliseconds = x.Milliseconds,
                            Bytes = x.Bytes,
                            UnitPrice = x.UnitPrice
                        }).ToList();
                    break;
                }

                default:
                    results = (from x in context.Tracks
                               orderby x.Name
                               where x.Album.AlbumId == argId
                               select new TrackList
                    {
                        TrackID = x.TrackId,
                        Name = x.Name,
                        Title = x.Album.Title,
                        MediaName = x.MediaType.Name,
                        GenreName = x.Genre.Name,
                        Composer = x.Composer,
                        Milliseconds = x.Milliseconds,
                        Bytes = x.Bytes,
                        UnitPrice = x.UnitPrice
                    }).ToList();
                    break;
                } //eos
                return(results);
            }
        } //eom
 public PlaylistRepository(ChinookContext context)
 {
     _context = context;
 }
Ejemplo n.º 11
0
 public GenreRepository(ChinookContext context)
 {
     _context = context;
 }
 public EmployeesController(ChinookContext context)
 {
     _context = context;
 }
 public InvoiceLinesController(ChinookContext context)
 {
     _context = context;
 }
Ejemplo n.º 14
0
 public EfCreateTrackCommand(ChinookContext context, CreateTrackValidator validator)
 {
     _context   = context;
     _validator = validator;
 }
Ejemplo n.º 15
0
 public InvoiceLineRepository(ChinookContext context)
 {
     _context = context;
 }
 public JwtManager(ChinookContext context)
 {
     _context = context;
 }
Ejemplo n.º 17
0
 static void DeleteThatTrack()
 {
     using var context = new ChinookContext(s_dbContextOptions);
     context.Remove(context.Tracks.Single(x => x.Name == "testtrackname"));
     context.SaveChanges();
 }
 public ChinookInvoicesController(ChinookContext context)
 {
     _context = context;
 }
 public GenresController(ChinookContext context)
 {
     _context = context;
 }
 public GenreRepository(ChinookContext context, IMemoryCache memoryCache)
 {
     _context = context;
     _cache   = memoryCache;
 }
Ejemplo n.º 21
0
 public EmployeeRepository(ChinookContext context)
 {
     _context = context;
 }
Ejemplo n.º 22
0
 public MediaTypesController(ChinookContext context)
 {
     _context = context;
 }
Ejemplo n.º 23
0
 public TrackRepository(ChinookContext context)
 {
     _context = context;
 }
Ejemplo n.º 24
0
 public AlbumService(ChinookContext context, ICommandFactory given)
 {
     _context     = context;
     _commandFact = given;
 }
Ejemplo n.º 25
0
 public DetalleFacturasController(ChinookContext context)
 {
     _context = context;
 }
Ejemplo n.º 26
0
 public ChinookTests()
 {
     _dbContext = new ChinookContext();
 }
 public PlaylistTrackRepository(ChinookContext context)
 {
     _context = context ?? throw new ArgumentNullException(nameof(context));
 }
 public DefaultArtistsService(ChinookContext context)
 {
     _context = context;
 }
 public ArtistsController(ChinookContext context)
 {
     _context = context;
 }
Ejemplo n.º 30
0
 static void Main(string[] args)
 {
     using var db = new ChinookContext();
     db.Customers.ToList();
 }
 public CustomerRepository(ChinookContext context)
 {
     _context = context;
 }
 public CustomersController(ChinookContext context)
 {
     _context = context;
 }
Ejemplo n.º 33
0
 private static IUnitOfWork CreateUnitOfWork()
 {
     IUnitOfWork uow = new ChinookContext();
     return uow;
 }
Ejemplo n.º 34
0
 public MediaTypeRepository(ChinookContext context)
 {
     _context = context;
 }