static void Main(string[] args) { using (var context = new NorthwindSlimContext()) { var employees = context.Employee.Select(e => new { Name = $"{e.FirstName} {e.LastName}", e.City, e.Country }); foreach (var e in employees) { Console.WriteLine($"{e.Name} {e.City} {e.Country} "); } } }
public static void Main(string[] args) { Console.WriteLine("Press Enter for Customers"); Console.ReadLine(); using (var context = new NorthwindSlimContext()) { var customers = context.Customer.OrderBy(c => c.CompanyName).ToList(); foreach (var c in customers) { Console.WriteLine($"{c.CompanyName} {c.City}"); } } }
static void Main(string[] args) { using (var context = new NorthwindSlimContext()) { Console.WriteLine("Categories:"); foreach (var category in context.Categories) { Console.WriteLine("{0} {1}", category.CategoryId, category.CategoryName); } Console.WriteLine("\nProducts:"); foreach (var product in context.Products) { Console.WriteLine("{0} {1} {2} {3}", product.ProductId, product.ProductName, product.UnitPrice, product.Category.CategoryName); } } }
public void ApplyChanges_Should_Mark_Entity_As_Added() { using (var context = new NorthwindSlimContext(_options)) { // Arrange var product = new Product { ProductId = 1, ProductName = "Chai", UnitPrice = 10 }; product.TrackingState = TrackingState.Added; // Act context.ApplyChanges(product); // Assert Assert.Equal(EntityState.Added, context.Entry(product).State); } }
public ProductsController(NorthwindSlimContext context) { _context = context; }
public CustomerService() { _dbContext = new NorthwindSlimContext(); }
public OrderController(NorthwindSlimContext context) { _context = context; }
public OrderService() { _dbContext = new NorthwindSlimContext(); }
public EmployeeController(NorthwindSlimContext context) { _context = context; }
public CustomerController(NorthwindSlimContext context) { _context = context; }
public ProductRepository(NorthwindSlimContext context) { _context = context; }