static void Main(string[] args) { try { foreach (var dbContext in ConfigurationManager.DatabaseContexts) { DbContext dataContext; string contextFolder = String.Empty; switch (dbContext.Key) { case "SampleDbContext": { dataContext = new SampleDbContext(); contextFolder = "Sample"; break; } default: throw new NotSupportedException(String.Format("Unknow database context: {0}.", dbContext.Key)); } DatabaseHelper.SynchronizeModelBase64(dataContext, dbContext.Value, contextFolder); } } catch(Exception ex) { Console.WriteLine("Message: {0}", ex.Message); Console.WriteLine("InnerException: {0}", ex.InnerException); Console.ReadLine(); } }
static void Main(string[] args) { using (var ctx = new SampleDbContext()) { var teachers = ctx.People.OfType<Teacher>().ToList(); Console.WriteLine(teachers.Count); } Console.WriteLine("Press any key to continue..."); Console.ReadKey(); }
public BaseRequestCommandHandler(ILogger <BaseCommandHandler> logger, IHeaderService headerService, IMapper mapper, IRequestManager requestManager, SampleDbContext context) : base(logger) { _headerService = headerService ?? throw new ArgumentNullException(nameof(headerService)); _mapper = mapper ?? throw new ArgumentNullException(nameof(mapper)); _requestManager = requestManager ?? throw new ArgumentNullException(nameof(requestManager)); _context = context ?? throw new ArgumentNullException(nameof(context)); }
public HomeController(SampleDbContext dbContext) { this.dbContext = dbContext; }
public SampleContextDbService(SampleDbContext context) { _context = context; }
/// <summary> /// Using DI to inject infrastructure persistence Repositories /// </summary> /// <param name="mediator"></param> /// <param name="couponService"></param> public DeleteProductCommandHandler(ILogger <BaseCommandHandler> logger, IHeaderService headerService, IMapper mapper, IRequestManager requestManager, SampleDbContext context) : base(logger, headerService, mapper, requestManager, context) { }
public DefaultLanguagesCreator(SampleDbContext context) { _context = context; }
public PublishProductHandler(SampleDbContext dbContext) { _dbContext = dbContext; }
public GetAllProductsHandler(SampleDbContext dbContext) { _dbContext = dbContext; }
protected BaseListRepo(SampleDbContext db) : base(db) { }
public SampleController(SampleDbContext context) { _context = context; }
public OnboardingController(SampleDbContext dbContext, IOptions <MicrosoftIdentityOptions> microsoftIdentityOptions, IConfiguration configuration) { this.dbContext = dbContext; this.microsoftIdentityOptions = microsoftIdentityOptions.Value; this.configuration = configuration; }
public PersonController(SampleDbContext context) { _context = context; }
public void AutoMapperProjection() { var sampleDbContext = new SampleDbContext(); var categories = sampleDbContext.Categories.ProjectTo <CategoryDto>(_mapper.ConfigurationProvider).ToList(); }
public WeatherForecastController(ILogger <WeatherForecastController> logger, SampleDbContext sampleDbContext) { _logger = logger; this.sampleDbContext = sampleDbContext; }
public static void Initialize(IServiceProvider serviceProvider) { using var dbContext = new SampleDbContext(serviceProvider.GetRequiredService <DbContextOptions <SampleDbContext> >()); if (dbContext.Orders.Any()) { return; } var shipperCities = new[] { "Guadalajara, JAL, Mexico", "Los Angeles, CA, USA", "Portland, OR, USA", "Leon, GTO, Mexico", "Boston, MA, USA" }; var companies = new[] { "Unosquare LLC", "Advanced Technology Systems", "Super La Playa", "Vesta", "Microsoft", "Oxxo", "Simian" }; dbContext.Products.AddRange(new Product { Name = "CocaCola" }, new Product { Name = "Pepsi" }, new Product { Name = "Starbucks" }, new Product { Name = "Donut" }); dbContext.SaveChanges(); var rand = new Random(); var products = dbContext.Products.ToArray(); for (var i = 0; i < 500; i++) { var order = new Order { //CreatedUserId = users[rand.Next(users.Count - 1)].Id, CustomerName = companies[rand.Next(companies.Length - 1)], IsShipped = rand.Next(10) > 5, ShipperCity = shipperCities[rand.Next(shipperCities.Length - 1)], ShippedDate = DateTime.Now.AddDays(1 - rand.Next(10)), OrderType = rand.Next(30), Address = "Address " + i, PostalCode = "500-" + i, PhoneNumber = "1-800-123-1" + i }; for (var k = 0; k < rand.Next(10); k++) { order.Details.Add(new() { Price = rand.Next(10), Description = "Product ID" + rand.Next(1000), Quantity = rand.Next(10), ProductID = products[rand.Next(products.Length - 1)].ProductID }); } order.Amount = order.Details.Sum(x => x.Price * x.Quantity); dbContext.Orders.Add(order); } dbContext.SaveChanges(); }
public DefaultEditionCreator(SampleDbContext context) { _context = context; }
public StudentService(SampleDbContext dbcontext) { _dbcontext = dbcontext; }
public UpdateProductHandler(SampleDbContext dbContext) { _dbContext = dbContext; }
static async Task CreateDb(SampleDbContext context) { await context.Database.EnsureCreatedAsync(); var company1 = new Company { Id = 1, Content = "Company1" }; var employee1 = new Employee { Id = 2, CompanyId = company1.Id, Content = "Employee1", Age = 25 }; var employee2 = new Employee { Id = 3, CompanyId = company1.Id, Content = "Employee2", Age = 31 }; var company2 = new Company { Id = 4, Content = "Company2" }; var employee4 = new Employee { Id = 5, CompanyId = company2.Id, Content = "Employee4", Age = 34 }; var company3 = new Company { Id = 6, Content = "Company3" }; var company4 = new Company { Id = 7, Content = "Company4" }; var employee5 = new Employee { Id = 8, Content = null, CompanyId = company2.Id }; context.AddRange(company1, employee1, employee2, company2, company3, company4, employee4, employee5); var orderDetail1 = new OrderDetail { Id = 1, BillingAddress = new() { AddressLine1 = "1 Street", AreaCode = "1234", State = "New South Wales", Country = "Australia" }, ShippingAddress = new() { AddressLine1 = "1 Street", AreaCode = "1234", State = "New South Wales", Country = "Australia" } }; context.OrderDetails.Add(orderDetail1); await context.SaveChangesAsync(); }
public CustomerRepository(SampleDbContext dbContext) { this.dbContext = dbContext; }
public InitialHostDbBuilder(SampleDbContext context) { _context = context; }
public MyRepository(SampleDbContext dbContext) : base(dbContext) { this.dbContext = dbContext; }
public PersonRepository(SampleDbContext dbContext) { _dbContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext)); }
public ProductController(SampleDbContext context) { _context = context; }
public SampleDbService(HttpClient httpClient, SampleDbContext context, NavigationManager navigationManager) { this.httpClient = httpClient; this.context = context; this.navigationManager = navigationManager; }
public SignupController(SampleDbContext DbContext) { this.DbContext = DbContext; }
public WithdrawProductHandler(SampleDbContext dbContext) { _dbContext = dbContext; }
public DeleteProductHandler(SampleDbContext dbContext) { _dbContext = dbContext; }
/// <summary> /// Ctor /// </summary> /// <param name="sampleDbContext"> /// DB Context /// </param> public DefaultController(SampleDbContext sampleDbContext) { this.sampleDbContext = sampleDbContext; }
public GetPublishedProductsHandler(SampleDbContext dbContext) { _dbContext = dbContext; }
public OnboardingController(SampleDbContext dbContext, IOptions <AzureADOptions> azureADOptions, IConfiguration configuration) { this.dbContext = dbContext; this.azureADOptions = azureADOptions.Value; this.configuration = configuration; }