예제 #1
0
        private void FillSuppliersWithData()
        {
            using (var ctx = new sampleDbEntities(_conn))
            {
                var Suppliers = ctx.Suppliers.Where(x => x.Id > -1).ToList();
                foreach (var supplier in Suppliers)
                {
                    supplier.moreColumn1  = RandomString(50);
                    supplier.moreColumn2  = RandomString(50);
                    supplier.moreColumn3  = RandomString(50);
                    supplier.moreColumn4  = RandomString(50);
                    supplier.moreColumn5  = RandomString(50);
                    supplier.moreColumn6  = RandomString(50);
                    supplier.moreColumn7  = RandomString(50);
                    supplier.moreColumn8  = RandomString(50);
                    supplier.moreColumn9  = RandomString(50);
                    supplier.moreColumn10 = RandomString(50);
                    supplier.moreColumn11 = RandomString(50);
                    supplier.moreColumn12 = RandomString(50);
                    supplier.moreColumn13 = RandomString(50);
                    supplier.moreColumn14 = RandomString(50);
                    supplier.moreColumn15 = RandomString(50);
                    supplier.moreColumn16 = RandomString(50);
                    supplier.moreColumn17 = RandomString(50);
                    supplier.moreColumn18 = RandomString(50);
                    supplier.moreColumn19 = RandomString(50);
                    supplier.moreColumn20 = RandomString(50);
                }

                ctx.SaveChanges();
            }
        }
예제 #2
0
        private void FillOrderItemsWithData()
        {
            using (var ctx = new sampleDbEntities(_conn))
            {
                var OrderItems = ctx.OrderItems.Where(x => x.Id > 302).ToList();
                foreach (var orderItem in OrderItems)
                {
                    orderItem.moreColumn1  = RandomString(50);
                    orderItem.moreColumn2  = RandomString(50);
                    orderItem.moreColumn3  = RandomString(50);
                    orderItem.moreColumn4  = RandomString(50);
                    orderItem.moreColumn5  = RandomString(50);
                    orderItem.moreColumn6  = RandomString(50);
                    orderItem.moreColumn7  = RandomString(50);
                    orderItem.moreColumn8  = RandomString(50);
                    orderItem.moreColumn9  = RandomString(50);
                    orderItem.moreColumn10 = RandomString(50);
                    orderItem.moreColumn11 = RandomString(50);
                    orderItem.moreColumn12 = RandomString(50);
                    orderItem.moreColumn13 = RandomString(50);
                    orderItem.moreColumn14 = RandomString(50);
                    orderItem.moreColumn15 = RandomString(50);
                    orderItem.moreColumn16 = RandomString(50);
                    orderItem.moreColumn17 = RandomString(50);
                    orderItem.moreColumn18 = RandomString(50);
                    orderItem.moreColumn19 = RandomString(50);
                    orderItem.moreColumn20 = RandomString(50);

                    ctx.SaveChanges();
                }
            }
        }
예제 #3
0
        private void FillProductsWithData()
        {
            using (var ctx = new sampleDbEntities(_conn))
            {
                var Products = ctx.Products.Where(x => x.Id > -1).ToList();
                foreach (var product in Products)
                {
                    product.moreColumn1  = RandomString(50);
                    product.moreColumn2  = RandomString(50);
                    product.moreColumn3  = RandomString(50);
                    product.moreColumn4  = RandomString(50);
                    product.moreColumn5  = RandomString(50);
                    product.moreColumn6  = RandomString(50);
                    product.moreColumn7  = RandomString(50);
                    product.moreColumn8  = RandomString(50);
                    product.moreColumn9  = RandomString(50);
                    product.moreColumn10 = RandomString(50);
                    product.moreColumn11 = RandomString(50);
                    product.moreColumn12 = RandomString(50);
                    product.moreColumn13 = RandomString(50);
                    product.moreColumn14 = RandomString(50);
                    product.moreColumn15 = RandomString(50);
                    product.moreColumn16 = RandomString(50);
                    product.moreColumn17 = RandomString(50);
                    product.moreColumn18 = RandomString(50);
                    product.moreColumn19 = RandomString(50);
                    product.moreColumn20 = RandomString(50);
                }

                ctx.SaveChanges();
            }
        }
예제 #4
0
 public List <Customer> GetCustomerById(int id)
 {
     using (var ctx = new sampleDbEntities(_conn))
     {
         var customers = ctx.Customers.Where(x => x.Id == id).ToList();
         return(customers);
     }
 }
예제 #5
0
        public List <Customer> GetAllCustomers()
        {
            using (var ctx = new sampleDbEntities(_conn))
            {
                var customers = ctx.Customers.Where(x => x.Id > -1).ToList();

                return(customers);
            }
        }
예제 #6
0
        public List <AllTablesJoined> GetJoinedTablesByCustomers(int amount)
        {
            using (var ctx = new sampleDbEntities(_conn))
            {
                var allTablesJoined = (from cu in ctx.Customers
                                       join ord in ctx.Orders on cu.Id equals ord.CustomerId
                                       join oi in ctx.OrderItems on ord.Id equals oi.OrderId
                                       join pro in ctx.Products on oi.ProductId equals pro.Id
                                       join sup in ctx.Suppliers on pro.SupplierId equals sup.Id
                                       where cu.Id <= amount
                                       select new AllTablesJoined()
                {
                    Customer = cu, Order = ord, OrderItem = oi, Product = pro, Supplier = sup
                })
                                      .ToList();

                return(allTablesJoined);
            }
        }