コード例 #1
0
ファイル: Program.cs プロジェクト: ezeh2/ezeh2.github.io
        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();
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: ezeh2/ezeh2.github.io
 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();
     }
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: ezeh2/ezeh2.github.io
        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);
            }
        }
コード例 #4
0
 public AlbumRepository(ChinookContext context)
 {
     _context = context;
 }
コード例 #5
0
 public EfDeletePlaylistCommand(ChinookContext context) : base(context)
 {
 }
コード例 #6
0
 public AlbumsController(ChinookContext context)
 {
     _context = context;
 }
コード例 #7
0
 public TracksController(ChinookContext context)
 {
     _context = context;
 }
コード例 #8
0
 public ArtistRepository(ChinookContext context)
 {
     _context = context;
 }
コード例 #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
コード例 #10
0
 public PlaylistRepository(ChinookContext context)
 {
     _context = context;
 }
コード例 #11
0
 public GenreRepository(ChinookContext context)
 {
     _context = context;
 }
コード例 #12
0
 public EmployeesController(ChinookContext context)
 {
     _context = context;
 }
コード例 #13
0
 public InvoiceLinesController(ChinookContext context)
 {
     _context = context;
 }
コード例 #14
0
 public EfCreateTrackCommand(ChinookContext context, CreateTrackValidator validator)
 {
     _context   = context;
     _validator = validator;
 }
コード例 #15
0
 public InvoiceLineRepository(ChinookContext context)
 {
     _context = context;
 }
コード例 #16
0
 public JwtManager(ChinookContext context)
 {
     _context = context;
 }
コード例 #17
0
 static void DeleteThatTrack()
 {
     using var context = new ChinookContext(s_dbContextOptions);
     context.Remove(context.Tracks.Single(x => x.Name == "testtrackname"));
     context.SaveChanges();
 }
コード例 #18
0
 public ChinookInvoicesController(ChinookContext context)
 {
     _context = context;
 }
コード例 #19
0
 public GenresController(ChinookContext context)
 {
     _context = context;
 }
コード例 #20
0
 public GenreRepository(ChinookContext context, IMemoryCache memoryCache)
 {
     _context = context;
     _cache   = memoryCache;
 }
コード例 #21
0
 public EmployeeRepository(ChinookContext context)
 {
     _context = context;
 }
コード例 #22
0
 public MediaTypesController(ChinookContext context)
 {
     _context = context;
 }
コード例 #23
0
 public TrackRepository(ChinookContext context)
 {
     _context = context;
 }
コード例 #24
0
 public AlbumService(ChinookContext context, ICommandFactory given)
 {
     _context     = context;
     _commandFact = given;
 }
コード例 #25
0
 public DetalleFacturasController(ChinookContext context)
 {
     _context = context;
 }
コード例 #26
0
 public ChinookTests()
 {
     _dbContext = new ChinookContext();
 }
コード例 #27
0
 public PlaylistTrackRepository(ChinookContext context)
 {
     _context = context ?? throw new ArgumentNullException(nameof(context));
 }
コード例 #28
0
 public DefaultArtistsService(ChinookContext context)
 {
     _context = context;
 }
コード例 #29
0
 public ArtistsController(ChinookContext context)
 {
     _context = context;
 }
コード例 #30
0
 static void Main(string[] args)
 {
     using var db = new ChinookContext();
     db.Customers.ToList();
 }
コード例 #31
0
 public CustomerRepository(ChinookContext context)
 {
     _context = context;
 }
コード例 #32
0
 public CustomersController(ChinookContext context)
 {
     _context = context;
 }
コード例 #33
0
ファイル: Program.cs プロジェクト: BoykoDmitry/csharp
 private static IUnitOfWork CreateUnitOfWork()
 {
     IUnitOfWork uow = new ChinookContext();
     return uow;
 }
コード例 #34
0
 public MediaTypeRepository(ChinookContext context)
 {
     _context = context;
 }