c17c9cd329
Using the short namesapce declaration for conciseness
39 lines
992 B
C#
39 lines
992 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
using Icarus.Models;
|
|
|
|
namespace Icarus.Database.Contexts;
|
|
|
|
public class ArtistContext : DbContext
|
|
{
|
|
public DbSet<Artist> Artists { get; set; }
|
|
|
|
public ArtistContext(DbContextOptions<ArtistContext> options) : base (options) { }
|
|
public ArtistContext(string connString) : base(new DbContextOptionsBuilder<ArtistContext>()
|
|
.UseMySQL(connString).Options)
|
|
{
|
|
}
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
modelBuilder.Entity<Artist>()
|
|
.ToTable("Artist");
|
|
}
|
|
|
|
public Artist RetrieveRecord(Artist artist)
|
|
{
|
|
|
|
return Artists.FirstOrDefault(arst => arst.ArtistID == artist.ArtistID);
|
|
}
|
|
|
|
|
|
public bool DoesRecordExist(Artist artist)
|
|
{
|
|
return Artists.FirstOrDefault(arst => arst.ArtistID == artist.ArtistID) != null ? true : false;
|
|
}
|
|
}
|