Skip to content

Instantly share code, notes, and snippets.

@codehaks
Created October 15, 2019 07:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codehaks/f6d8639af9220cb9d2da26993a69ae5b to your computer and use it in GitHub Desktop.
Save codehaks/f6d8639af9220cb9d2da26993a69ae5b to your computer and use it in GitHub Desktop.
Dependecny injection in console app
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