public ClientServerEvalTests()
 {
     _context = new AdventureWorksContext();
 }
 public RawSqlWithLinqTests()
 {
     _context = new AdventureWorksContext();
 }
        private static void AddAddressesToEmployees(AdventureWorksContext ctx)
        {
            if (ctx.Person.Any())
            {
                var peopleAddresses = SampleData.GetPeopleAddresses();

                var query = ctx.Person.AsNoTracking()
                            .Where(p => p.FirstName == "Ken" && p.MiddleName == "J" && p.LastName == "Sanchez")
                            .Select(obj => new { obj.BusinessEntityID })
                            .SingleOrDefault();

                var address = peopleAddresses.FirstOrDefault(a => a.AddressLine1 == "4350 Minute Dr." && a.City == "Newport Hills");
                if (address != null)
                {
                    address.BusinessEntityAddressObj.BusinessEntityID = query.BusinessEntityID;
                    ctx.Address.Add(address);
                }

                query = ctx.Person.AsNoTracking()
                        .Where(p => p.FirstName == "Terri" && p.MiddleName == "Lee" && p.LastName == "Duffy")
                        .Select(v => new { v.BusinessEntityID })
                        .SingleOrDefault();

                address = peopleAddresses.FirstOrDefault(a => a.AddressLine1 == "7559 Worth Ct." && a.City == "Renton");
                if (address != null)
                {
                    address.BusinessEntityAddressObj.BusinessEntityID = query.BusinessEntityID;
                    ctx.Address.Add(address);
                }

                query = ctx.Person.AsNoTracking()
                        .Where(p => p.FirstName == "Gail" && p.MiddleName == "A" && p.LastName == "Erickson")
                        .Select(v => new { v.BusinessEntityID })
                        .SingleOrDefault();

                address = peopleAddresses.FirstOrDefault(a => a.AddressLine1 == "9435 Breck Court" && a.City == "Bellevue");
                if (address != null)
                {
                    address.BusinessEntityAddressObj.BusinessEntityID = query.BusinessEntityID;
                    ctx.Address.Add(address);
                }

                query = ctx.Person.AsNoTracking()
                        .Where(p => p.FirstName == "Jossef" && p.MiddleName == "H" && p.LastName == "Goldberg")
                        .Select(v => new { v.BusinessEntityID })
                        .SingleOrDefault();

                address = peopleAddresses.FirstOrDefault(a => a.AddressLine1 == "5670 Bel Air Dr." && a.City == "Renton");
                if (address != null)
                {
                    address.BusinessEntityAddressObj.BusinessEntityID = query.BusinessEntityID;
                    ctx.Address.Add(address);
                }

                query = ctx.Person.AsNoTracking()
                        .Where(p => p.FirstName == "Diane" && p.MiddleName == "L" && p.LastName == "Margheim")
                        .Select(v => new { v.BusinessEntityID })
                        .SingleOrDefault();

                address = peopleAddresses.FirstOrDefault(a => a.AddressLine1 == "475 Santa Maria" && a.City == "Everett");
                if (address != null)
                {
                    address.BusinessEntityAddressObj.BusinessEntityID = query.BusinessEntityID;
                    ctx.Address.Add(address);
                }

                ctx.SaveChanges();
            }
        }
        private static void AddAddressesAndContactsToVendor(AdventureWorksContext ctx)
        {
            if (ctx.Vendor.Any())
            {
                var vendorAddresses = SampleData.GetVendorAddresses();

                // AUSTRALI0001
                var vendor = ctx.Vendor.AsNoTracking()
                             .Where(v => v.AccountNumber == "AUSTRALI0001")
                             .Select(c => new { ID = c.BusinessEntityID })
                             .SingleOrDefault();

                var address = vendorAddresses.First(a => a.AddressLine1 == "28 San Marino Ct" && a.City == "Bellingham");
                if (address != null)
                {
                    address.BusinessEntityAddressObj.BusinessEntityID = vendor.ID;
                    ctx.Address.Add(address);
                }

                var contact1 = ctx.Person.AsNoTracking()
                               .Where(c => c.FirstName == "Paula" && c.MiddleName == "B." && c.LastName == "Moberly")
                               .Select(c => new { ID = c.BusinessEntityID })
                               .SingleOrDefault();
                var contact2 = ctx.Person.AsNoTracking()
                               .Where(c => c.FirstName == "Charlene" && c.MiddleName == "J." && c.LastName == "Wojcik")
                               .Select(c => new { ID = c.BusinessEntityID })
                               .SingleOrDefault();
                var contact3 = ctx.Person.AsNoTracking()
                               .Where(c => c.FirstName == "Jo" && c.MiddleName == "J." && c.LastName == "Zimmerman")
                               .Select(c => new { ID = c.BusinessEntityID })
                               .SingleOrDefault();

                var bc1 = new BusinessEntityContact {
                    BusinessEntityID = vendor.ID, PersonID = contact1.ID, ContactTypeID = 18
                };
                var bc2 = new BusinessEntityContact {
                    BusinessEntityID = vendor.ID, PersonID = contact2.ID, ContactTypeID = 19
                };
                var bc3 = new BusinessEntityContact {
                    BusinessEntityID = vendor.ID, PersonID = contact3.ID, ContactTypeID = 17
                };
                ctx.BusinessEntityContact.AddRange(new List <BusinessEntityContact> {
                    bc1, bc2, bc3
                });


                // TRIKES0001
                vendor = ctx.Vendor.AsNoTracking()
                         .Where(v => v.AccountNumber == "TRIKES0001")
                         .Select(c => new { ID = c.BusinessEntityID })
                         .SingleOrDefault();

                address = vendorAddresses.First(a => a.AddressLine1 == "90 Sunny Ave" && a.City == "Berkeley");
                if (address != null)
                {
                    address.BusinessEntityAddressObj.BusinessEntityID = vendor.ID;
                    ctx.Address.Add(address);
                }

                var contact4 = ctx.Person.AsNoTracking()
                               .Where(c => c.FirstName == "William" && c.MiddleName == "J." && c.LastName == "Monroe")
                               .Select(c => new { ID = c.BusinessEntityID })
                               .SingleOrDefault();

                var bc4 = new BusinessEntityContact {
                    BusinessEntityID = vendor.ID, PersonID = contact4.ID, ContactTypeID = 18
                };
                ctx.BusinessEntityContact.Add(bc4);


                // LIGHTSP0001
                vendor = ctx.Vendor.AsNoTracking()
                         .Where(v => v.AccountNumber == "LIGHTSP0001")
                         .Select(c => new { ID = c.BusinessEntityID })
                         .SingleOrDefault();

                address = vendorAddresses.First(a => a.AddressLine1 == "298 Sunnybrook Drive" && a.City == "Spring Valley");
                if (address != null)
                {
                    address.BusinessEntityAddressObj.BusinessEntityID = vendor.ID;
                    ctx.Address.Add(address);
                }

                var contact5 = ctx.Person.AsNoTracking()
                               .Where(c => c.FirstName == "Marie" && c.MiddleName == "E." && c.LastName == "Moya")
                               .Select(c => new { ID = c.BusinessEntityID })
                               .SingleOrDefault();

                var bc5 = new BusinessEntityContact {
                    BusinessEntityID = vendor.ID, PersonID = contact5.ID, ContactTypeID = 17
                };
                ctx.BusinessEntityContact.Add(bc5);

                // DFWBIRE0001
                var dfwVendor = ctx.Vendor.AsNoTracking()
                                .Where(v => v.AccountNumber == "DFWBIRE0001")
                                .Select(c => new { ID = c.BusinessEntityID })
                                .SingleOrDefault();

                var terriPhide = ctx.Person.AsNoTracking()
                                 .Where(c => c.FirstName == "Terri" && c.LastName == "Phide")
                                 .Select(c => new { ID = c.BusinessEntityID })
                                 .SingleOrDefault();

                var bc6 = new BusinessEntityContact {
                    BusinessEntityID = dfwVendor.ID, PersonID = terriPhide.ID, ContactTypeID = 17
                };
                ctx.BusinessEntityContact.Add(bc6);


                // DESOTOB0001
                var desotoVendor = ctx.Vendor.AsNoTracking()
                                   .Where(v => v.AccountNumber == "DESOTOB0001")
                                   .Select(c => new { ID = c.BusinessEntityID })
                                   .SingleOrDefault();

                var address1 = vendorAddresses.First(a => a.AddressLine1 == "1900 Desoto Court" && a.City == "Desoto");
                if (address1 != null)
                {
                    address1.BusinessEntityAddressObj.BusinessEntityID = desotoVendor.ID;
                    address1.BusinessEntityAddressObj.AddressTypeID    = 3;
                    ctx.Address.Add(address1);
                }

                var address2 = vendorAddresses.FirstOrDefault(a => a.AddressLine1 == "211 East Pleasant Run Rd" && a.City == "Desoto");
                if (address2 != null)
                {
                    address2.BusinessEntityAddressObj.BusinessEntityID = desotoVendor.ID;
                    address2.BusinessEntityAddressObj.AddressTypeID    = 7;
                    ctx.Address.Add(address2);
                }

                var johnnyDough = ctx.Person.AsNoTracking()
                                  .Where(c => c.FirstName == "Johnny" && c.LastName == "Dough")
                                  .Select(c => new { ID = c.BusinessEntityID })
                                  .SingleOrDefault();

                var bc7 = new BusinessEntityContact {
                    BusinessEntityID = desotoVendor.ID, PersonID = johnnyDough.ID, ContactTypeID = 17
                };
                ctx.BusinessEntityContact.Add(bc7);


                // CYCLERU0001
                var rusVendor = ctx.Vendor.AsNoTracking()
                                .Where(v => v.AccountNumber == "CYCLERU0001")
                                .Select(c => new { ID = c.BusinessEntityID })
                                .SingleOrDefault();

                address = vendorAddresses.FirstOrDefault(a => a.AddressLine1 == "6266 Melody Lane" && a.City == "Dallas");
                if (address != null)
                {
                    address.BusinessEntityAddressObj.BusinessEntityID = rusVendor.ID;
                    address.BusinessEntityAddressObj.AddressTypeID    = 3;
                    ctx.Address.Add(address);
                }


                ctx.SaveChanges();
            }
        }
 public CustomerAddressesController(AdventureWorksContext context)
 {
     _context = context;
 }
Beispiel #6
0
 public TransactionTests()
 {
     _context = new AdventureWorksContext();
 }
Beispiel #7
0
 public EmployeesController(AdventureWorksContext context)
 {
     _context = context;
 }
Beispiel #8
0
 public LinqExecutionTests()
 {
     _context = new AdventureWorksContext();
 }
Beispiel #9
0
 public ExplicityCompliledQueryTests()
 {
     _context = new AdventureWorksContext();
 }
Beispiel #10
0
 public ProjectionTests()
 {
     _context = new AdventureWorksContext();
 }
Beispiel #11
0
 public RepositoryBase(AdventureWorksContext context, ILoggerManager logger)
 {
     DbContext  = context;
     RepoLogger = logger;
 }
 public CulturesController(AdventureWorksContext context)
 {
     _context = context;
 }
 public RelatedDataSaveTests()
 {
     _context = new AdventureWorksContext();
 }
 public ConcurrencyTests()
 {
     _context = new AdventureWorksContext();
 }
 public GlobalQueryFilterTests()
 {
     _context = new AdventureWorksContext();
 }
 public PersonPhoneRepository(AdventureWorksContext context, ILoggerManager logger)
     : base(context, logger)
 {
 }
 public UpdateCustomerCommandHandler(AdventureWorksContext ctx, IMapper mapper)
 {
     _ctx    = ctx;
     _mapper = mapper;
 }
 public StateProvincesController(AdventureWorksContext context)
 {
     _context = context;
 }
Beispiel #19
0
 public BusinessEntityAddressesController(AdventureWorksContext context)
 {
     _context = context;
 }
Beispiel #20
0
 public ScalarFunctionTests()
 {
     _context = new AdventureWorksContext();
 }
 public PagingTests()
 {
     _context = new AdventureWorksContext();
 }
 public BasicSaveTests()
 {
     _context = new AdventureWorksContext();
 }
Beispiel #23
0
 public VendorRepository(AdventureWorksContext context, ILoggerManager logger)
     : base(context, logger)
 {
 }
        private static void AddEmployeeDeptHistoryToDb(AdventureWorksContext ctx)
        {
            if (ctx.Employee.Any())
            {
                // Get department and shift ID's
                var engineering = ctx.Department
                                  .AsNoTracking()
                                  .Where(d => d.Name == "Engineering")
                                  .Select(obj => new { deptID = obj.DepartmentID })
                                  .SingleOrDefault();

                var RD = ctx.Department
                         .AsNoTracking()
                         .Where(d => d.Name == "Research and Development")
                         .Select(obj => new { deptID = obj.DepartmentID })
                         .SingleOrDefault();

                var executive = ctx.Department
                                .AsNoTracking()
                                .Where(d => d.Name == "Executive")
                                .Select(obj => new { deptID = obj.DepartmentID })
                                .SingleOrDefault();

                var toolDesign = ctx.Department
                                 .AsNoTracking()
                                 .Where(d => d.Name == "Tool Design")
                                 .Select(obj => new { deptID = obj.DepartmentID })
                                 .SingleOrDefault();

                var shift = ctx.Shift
                            .AsNoTracking()
                            .Where(s => s.Name == "Day")
                            .Select(obj => new { ID = obj.ShiftID })
                            .SingleOrDefault();

                // For each employee (there are five), get the BusinessEntityID
                // and create a EmployeeDepartmentHistory record
                var emp1 = ctx.Person
                           .AsNoTracking()
                           .Where(ee => ee.FirstName == "Ken" && ee.LastName == "Sanchez")
                           .Select(obj => new { ID = obj.BusinessEntityID })
                           .SingleOrDefault();

                var deptHistory1 = new EmployeeDepartmentHistory
                {
                    BusinessEntityID = emp1.ID,
                    DepartmentID     = executive.deptID,
                    ShiftID          = shift.ID,
                    StartDate        = new DateTime(2009, 1, 14)
                };

                var emp2 = ctx.Person
                           .AsNoTracking()
                           .Where(ee => ee.FirstName == "Terri" && ee.LastName == "Duffy")
                           .Select(obj => new { ID = obj.BusinessEntityID })
                           .SingleOrDefault();

                var deptHistory2 = new EmployeeDepartmentHistory
                {
                    BusinessEntityID = emp2.ID,
                    DepartmentID     = toolDesign.deptID,
                    ShiftID          = shift.ID,
                    StartDate        = new DateTime(2008, 1, 31)
                };

                var deptHistory2A = new EmployeeDepartmentHistory
                {
                    BusinessEntityID = emp2.ID,
                    DepartmentID     = engineering.deptID,
                    ShiftID          = shift.ID,
                    StartDate        = new DateTime(2010, 11, 3)
                };

                var emp3 = ctx.Person
                           .AsNoTracking()
                           .Where(ee => ee.FirstName == "Gail" && ee.LastName == "Erickson")
                           .Select(obj => new { ID = obj.BusinessEntityID })
                           .SingleOrDefault();

                var deptHistory3 = new EmployeeDepartmentHistory
                {
                    BusinessEntityID = emp3.ID,
                    DepartmentID     = executive.deptID,
                    ShiftID          = shift.ID,
                    StartDate        = new DateTime(2008, 1, 6)
                };

                var emp4 = ctx.Person
                           .AsNoTracking()
                           .Where(ee => ee.FirstName == "Jossef" && ee.LastName == "Goldberg")
                           .Select(obj => new { ID = obj.BusinessEntityID })
                           .SingleOrDefault();

                var deptHistory4 = new EmployeeDepartmentHistory
                {
                    BusinessEntityID = emp4.ID,
                    DepartmentID     = executive.deptID,
                    ShiftID          = shift.ID,
                    StartDate        = new DateTime(2008, 1, 24)
                };

                var emp5 = ctx.Person
                           .AsNoTracking()
                           .Where(ee => ee.FirstName == "Diane" && ee.LastName == "Margheim")
                           .Select(obj => new { ID = obj.BusinessEntityID })
                           .SingleOrDefault();

                var deptHistory5 = new EmployeeDepartmentHistory
                {
                    BusinessEntityID = emp5.ID,
                    DepartmentID     = RD.deptID,
                    ShiftID          = shift.ID,
                    StartDate        = new DateTime(2008, 12, 29)
                };

                // Add new EmployeeDepartmentHistory entities to the database
                ctx.EmployeeDepartmentHistory.AddRange(new List <EmployeeDepartmentHistory> {
                    deptHistory1, deptHistory2, deptHistory2A, deptHistory3, deptHistory4, deptHistory5
                });

                ctx.SaveChanges();
            }
        }
Beispiel #25
0
 public BatchingTests()
 {
     _context = new AdventureWorksContext();
 }
 public static void InitializeData(AdventureWorksContext ctx)
 {
     ClearData(ctx);
     SeedData(ctx);
 }
Beispiel #27
0
 public CustomersRepository(AdventureWorksContext dbContext) : base(dbContext)
 {
     _entities = dbContext;
 }
Beispiel #28
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, AdventureWorksContext context)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            app.UseMvc();

            // Enable middleware to serve generated Swagger as a JSON endpoint.
            app.UseSwagger();

            // Enable middleware to serve swagger-ui (HTML, JS, CSS etc.), specifying the Swagger JSON endpoint.
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "IronFramework API V1");
            });
        }
    public static async Task <IQueryable <InternetSaleInfo> > GetInternetSaleInfosQueryAsync(AdventureWorksContext context, DateTime?from, DateTime?until)
    {
        var query = await GetInternetSalesQueryAsync(context, from, until);

        return(query.Select(p => new InternetSaleInfo
        {
            Order = p.SalesOrderNumber,
            Pos = p.SalesOrderLineNumber,
            Customer = p.Customer.FirstName + " " + p.Customer.LastName,
            CustomerLocation = p.Customer.Geography.City + " (" + p.Customer.Geography.EnglishCountryRegionName + ")",
            Quantity = p.OrderQuantity,
            Price = p.UnitPrice,
            Currency = p.Currency.CurrencyName,
            Total = p.SalesAmount,
            Date = p.OrderDate,
            Promotion = p.Promotion.EnglishPromotionName
        }));
    }
 public void FixtureSetUp()
 {
     adventureWorksContext = new AdventureWorksContext("AdventureWorks");
 }
Beispiel #31
0
 public DataRepository(AdventureWorksContext repositoryContext)
 {
     this.RepositoryContext = repositoryContext;
 }