Ejemplo n.º 1
0
 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} ");
         }
     }
 }
Ejemplo n.º 2
0
        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}");
                }
            }
        }
Ejemplo n.º 3
0
        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);
                }
            }
        }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
 public ProductsController(NorthwindSlimContext context)
 {
     _context = context;
 }
Ejemplo n.º 6
0
 public CustomerService()
 {
     _dbContext = new NorthwindSlimContext();
 }
 public OrderController(NorthwindSlimContext context)
 {
     _context = context;
 }
Ejemplo n.º 8
0
 public OrderService()
 {
     _dbContext = new NorthwindSlimContext();
 }
Ejemplo n.º 9
0
 public EmployeeController(NorthwindSlimContext context)
 {
     _context = context;
 }
 public CustomerController(NorthwindSlimContext context)
 {
     _context = context;
 }
Ejemplo n.º 11
0
 public ProductRepository(NorthwindSlimContext context)
 {
     _context = context;
 }