public static async Task <DbArtist> GetArtistByNameAsync(this string name) { DbArtist artist = null; using (var scope = ApplicationServiceBase.App.GetScope()) using (var context = scope.ServiceProvider .GetRequiredService <MedialibraryDbContext>()) { var query = context.Artists .Where(i => i.Name == name); artist = await query.FirstOrDefaultAsync(); } return(artist); }
public static DbArtist GetArtistById(this int id) { DbArtist artist = null; using (var scope = ApplicationServiceBase.App.GetScope()) using (var context = scope.ServiceProvider .GetRequiredService <MedialibraryDbContext>()) { var query = context.Artists .Include(c => c.MediaFiles) .Include(c => c.Albums) .Where(i => i.Id == id); artist = query.SingleOrDefault(); } return(artist); }