// // GET: /Demo/ public ActionResult Index() { var db = new NorthwindDbContext(); var customers = db.Customers.ToList(); return View(customers); }
public IEnumerable<Order> Get() { using (var dbContext = new NorthwindDbContext()) { return (from o in dbContext.Orders select o).ToList(); } }
public Product Get(int id) { using (var dbContext = new NorthwindDbContext()) { return (from p in dbContext.Products where p.ProductID == id select p).FirstOrDefault(); } }
public IEnumerable<Supplier> Get() { using (var dbContext = new NorthwindDbContext()) { return dbContext.Suppliers.ToList(); } }
public IEnumerable<Category> Get() { using (var dbContext = new NorthwindDbContext()) { return dbContext.Categories.ToList(); } }
public IEnumerable<Order> Get(int id) { using (var dbContext = new NorthwindDbContext()) { return (from o in dbContext.Orders where o.OrderID == id select o).ToList(); } }
public IEnumerable<Product> Get() { try { using (var dbContext = new NorthwindDbContext()) { return dbContext.Products.ToList(); } } catch (Exception exception) { new LogEvent(exception.Message).Raise(); } return new List<Product>(); }
public HttpResponseMessage GetOrdersForCustomer(string customerId) { try { using (var dbContext = new NorthwindDbContext()) { var orders = (from o in dbContext.Orders.Include("OrderDetails") where o.CustomerID == customerId select o).ToList(); return Request.CreateResponse(HttpStatusCode.OK, orders); } } catch (Exception exception) { new LogEvent(exception.Message).Raise(); } return new HttpResponseMessage(HttpStatusCode.InternalServerError); }
//const string CustomersKey = "_Customers"; //const string EmployeesKey = "_Employees"; //const string ShippersKey = "_Shippers"; //const string ProductIDKey = "_ProductID"; public NorthwindDAL(NorthwindDbContext injectedContext, IMemoryCache memoryCache, ILogger <HomeController> logger) { _db = injectedContext; _cache = memoryCache; _logger = logger; }
public OrderRepository(NorthwindDbContext northwindDbContext) : base(northwindDbContext) { }
public GetProductQueryHandler(NorthwindDbContext context, IMapper mapper, ILogger <GetProductQueryHandler> logger) { this._mapper = mapper; this._logger = logger; this._dbContext = context; }
public DefaultEditionsCreator(NorthwindDbContext context) { _context = context; }
public EFTest(ITestOutputHelper testOutputHelper) { _testOutputHelper = testOutputHelper; _northwindDbContext = new NorthwindDbContext(); }
private List <Order> CreateTestOrders(NorthwindDbContext context) { // Create test entities var category1 = new Category { CategoryName = "Test Category 1" }; var category2 = new Category { CategoryName = "Test Category 2" }; var product1 = new Product { ProductName = "Test Product 1", UnitPrice = 10M, Category = category1 }; var product2 = new Product { ProductName = "Test Product 2", UnitPrice = 20M, Category = category2 }; var product3 = new Product { ProductName = "Test Product 3", UnitPrice = 30M, Category = category2 }; var customer1 = context.Customers .Include(c => c.Territory) .Include(c => c.CustomerSetting) .Single(c => c.CustomerId == TestCustomerId1); var customer2 = context.Customers .Include(c => c.Territory) .Include(c => c.CustomerSetting) .Single(c => c.CustomerId == TestCustomerId1); var detail1 = new OrderDetail { Product = product1, Quantity = 11, UnitPrice = 11M }; var detail2 = new OrderDetail { Product = product2, Quantity = 12, UnitPrice = 12M }; var detail3 = new OrderDetail { Product = product2, Quantity = 13, UnitPrice = 13M }; var detail4 = new OrderDetail { Product = product3, Quantity = 14, UnitPrice = 14M }; var order1 = new Order { OrderDate = DateTime.Today, Customer = customer1, OrderDetails = new List <OrderDetail> { detail1, detail2, } }; var order2 = new Order { OrderDate = DateTime.Today, Customer = customer2, OrderDetails = new List <OrderDetail> { detail3, detail4, } }; // Persist entities context.Orders.Add(order1); context.Orders.Add(order2); context.SaveChanges(); // Detach entities var objContext = ((IObjectContextAdapter)context).ObjectContext; objContext.Detach(order1); objContext.Detach(order2); // Clear reference properties product1.Category = null; product2.Category = null; product3.Category = null; customer1.Territory = null; customer2.Territory = null; customer1.CustomerSetting = null; customer2.CustomerSetting = null; detail1.Product = null; detail2.Product = null; detail3.Product = null; detail4.Product = null; order1.OrderDetails = new List <OrderDetail> { detail1, detail2 }; order2.OrderDetails = new List <OrderDetail> { detail3, detail4 }; // Return orders return(new List <Order> { order1, order2 }); }
public NorthwindData(NorthwindDbContext context) { this.context = context; }
// TODO: Всегда ли класс должен требовать зависимости через конструктор или, например, в данном // случае логичнее будет, чтобы он сам создал себе провайдер элементов ? public EmployeesManager(NorthwindDbContext context, IItemsProvider <Employees> employeesProvider) { _context = context; _empProvider = employeesProvider; }
protected override void Seed(NorthwindDbContext context) { }
public CreateRoomCommandHandler(NorthwindDbContext context) { _context = context; }
public WebApiFixture() { systemUnderTest = SystemUnderTest.ForStartup <Tests.Startup>(); northWindDbContext = (NorthwindDbContext)systemUnderTest.Services.GetService(typeof(NorthwindDbContext)); mapper = (IMapper)systemUnderTest.Services.GetService(typeof(IMapper)); }
public CustomersController(NorthwindDbContext context) { _context = context; }
public EmployeeController(NorthwindDbContext northwindDbContext) => _northwindDbContext = northwindDbContext;
public EmployeesWithManagersQueryHandler(NorthwindDbContext context) { _context = context; }
public EmployeeController(NorthwindDbContext db) { this.db = db; }
public PublisherNavigationPropertiesSynchronizer(GameStoreDbContext gameStoreDbContext, NorthwindDbContext northwindDbContext) { _gameStoreDbContext = gameStoreDbContext; _northwindDbContext = northwindDbContext; }
public OrdersViewComponent(NorthwindDbContext context) { _context = context; }
public UpdateCustomerCommandHandler(NorthwindDbContext context) { _context = context; }
public HomeController(NorthwindDbContext context, ICompositeViewEngine compositeViewEngine) : base(compositeViewEngine) { _context = context; }
public DeleteProductCommandHandler(NorthwindDbContext context) { _context = context; }
public GetCustomersListQueryHandlerTests(QueryTestFixture fixture) { _context = fixture.Context; _mapper = fixture.Mapper; }
private List <Employee> CreateTestEmployees(NorthwindDbContext context) { // Create test entities var area1 = new Area { AreaName = "Northern" }; var area2 = new Area { AreaName = "Southern" }; var territory1 = context.Territories.Single(t => t.TerritoryId == TestTerritoryId1); var territory2 = context.Territories.Single(t => t.TerritoryId == TestTerritoryId2); var territory3 = context.Territories.Single(t => t.TerritoryId == TestTerritoryId3); territory1.Area = area1; territory2.Area = area2; territory3.Area = area2; var employee1 = new Employee { FirstName = "Test", LastName = "Employee1", City = "San Fransicso", Country = "USA", Territories = new List <Territory> { territory1, territory2 } }; var employee2 = new Employee { FirstName = "Test", LastName = "Employee2", City = "Sacramento", Country = "USA", Territories = new List <Territory> { territory2, territory3 } }; // Persist entities context.Employees.Add(employee1); context.Employees.Add(employee2); context.SaveChanges(); // Detach entities var objContext = ((IObjectContextAdapter)context).ObjectContext; objContext.Detach(employee1); objContext.Detach(employee2); // Clear reference properties territory1.Area = null; territory2.Area = null; territory3.Area = null; employee1.Territories = new List <Territory> { territory1, territory2 }; employee2.Territories = new List <Territory> { territory2, territory3 }; // Return employees return(new List <Employee> { employee1, employee2 }); }
public NorthwindRepository(NorthwindDbContext dbContext) { _dbContext = dbContext; }
public CommandTestBase() { _context = NorthwindContextFactory.Create(); }
public EntityFrameworkRepository(NorthwindDbContext dbContext) { _dbContext = dbContext; }
public SuppliersController(NorthwindDbContext context) { _context = context; }
private readonly INotificationService _notificationService; // Usage shown in CreateRoomCommandHandler public UpdateRoomCommandHandler(NorthwindDbContext context, INotificationService notificationService) { _context = context; _notificationService = notificationService; }
public UnitTest1() { this.db = new NorthwindDbContext(); }
public GetCustomersListQueryHandler(NorthwindDbContext context, IMapper mapper) { _context = context; _mapper = mapper; }
public SampleDataController(NorthwindDbContext context) { _context = context; }
public VoteGameCommandHandler(NorthwindDbContext context, IMediator mediator) { _context = context; _mediator = mediator; }