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(); } }
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(); } }
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); } }
public AlbumRepository(ChinookContext context) { _context = context; }
public EfDeletePlaylistCommand(ChinookContext context) : base(context) { }
public AlbumsController(ChinookContext context) { _context = context; }
public TracksController(ChinookContext context) { _context = context; }
public ArtistRepository(ChinookContext context) { _context = context; }
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; }
public GenreRepository(ChinookContext context) { _context = context; }
public EmployeesController(ChinookContext context) { _context = context; }
public InvoiceLinesController(ChinookContext context) { _context = context; }
public EfCreateTrackCommand(ChinookContext context, CreateTrackValidator validator) { _context = context; _validator = validator; }
public InvoiceLineRepository(ChinookContext context) { _context = context; }
public JwtManager(ChinookContext context) { _context = context; }
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; }
public EmployeeRepository(ChinookContext context) { _context = context; }
public MediaTypesController(ChinookContext context) { _context = context; }
public TrackRepository(ChinookContext context) { _context = context; }
public AlbumService(ChinookContext context, ICommandFactory given) { _context = context; _commandFact = given; }
public DetalleFacturasController(ChinookContext context) { _context = context; }
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; }
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; }
private static IUnitOfWork CreateUnitOfWork() { IUnitOfWork uow = new ChinookContext(); return uow; }
public MediaTypeRepository(ChinookContext context) { _context = context; }