Created
October 15, 2019 07:07
-
-
Save codehaks/f6d8639af9220cb9d2da26993a69ae5b to your computer and use it in GitHub Desktop.
Dependecny injection in console app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using LinqLab.API; | |
using LinqLab.Models; | |
using Microsoft.EntityFrameworkCore; | |
using Microsoft.Extensions.DependencyInjection; | |
using Microsoft.Extensions.Logging; | |
using MoreLinq; | |
using System; | |
using System.Linq; | |
namespace LinqLab | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Console.WriteLine("Hello World!"); | |
var services = new ServiceCollection(); | |
services.AddDbContext<ChinookContext>( | |
options => options.UseSqlite("Data Source=chinook.db")); | |
services.AddTransient<Query>(); | |
var provider = services.BuildServiceProvider(); | |
//var db = provider.GetService<ChinookContext>() | |
//var model = db.Albums; | |
var query = provider.GetService<Query>(); | |
//var albums = query.GetAlbums(); | |
//query.MostPopularTracks(); | |
query.InvoiceCustomerSupport(); | |
//query.BestCustomers(); | |
//query.BestCustomers2(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment