public IQueryable <Customer> Where_FromDatabase() { CustomerType customerType = CustomerTypeBuilder.FromDatabase().Build(); IQueryable <Customer> result = customerDao.Query().Where(customer => customer.CustomerType == customerType); return(result); }
public async Task LoadSiteSpecificAmounts_SimpleLoad_Civilian() { OrganizationsDim organization; SitesDim site; VariablesDim variable; WaterSourcesDim waterSource; MethodsDim method; SiteSpecificAmount siteSpecificAmount; BeneficialUsesCV beneficialUses; BeneficialUsesCV primaryUseCategory; ReportYearCv reportYear; DateDim publicationDate; CustomerType customerType; SDWISIdentifier sdwisIdentifier; using (var db = new WaDEContext(Configuration.GetConfiguration())) { organization = await OrganizationsDimBuilder.Load(db); site = await SitesDimBuilder.Load(db); variable = await VariablesDimBuilder.Load(db); waterSource = await WaterSourcesDimBuilder.Load(db); method = await MethodsDimBuilder.Load(db); beneficialUses = await BeneficalUsesBuilder.Load(db); primaryUseCategory = await BeneficalUsesBuilder.Load(db); reportYear = await ReportYearCvBuilder.Load(db); publicationDate = await DateDimBuilder.Load(db); customerType = await CustomerTypeBuilder.Load(db); sdwisIdentifier = await SDWISIdentifierBuilder.Load(db); siteSpecificAmount = SiteSpecificAmountBuilder.Create(new SiteSpecificAmountBuilderOptions { RecordType = SiteSpecificRecordType.Civilian, Method = method, Organization = organization, DataPublicationDate = publicationDate, Site = site, Variable = variable, WaterSource = waterSource, BeneficialUse = beneficialUses, PrimaryUseCategory = primaryUseCategory, ReportYear = reportYear, CustomerType = customerType, SDWISIdentifier = sdwisIdentifier }); } siteSpecificAmount.PopulationServed.Should().NotBeNullOrEmpty("Required field"); siteSpecificAmount.CommunityWaterSupplySystem.Should().NotBeNullOrEmpty("Required field"); siteSpecificAmount.CustomerTypeCV.Should().NotBeNullOrEmpty("Required field"); siteSpecificAmount.SDWISIdentifier.Should().NotBeNullOrEmpty("Required field"); var sut = CreateWaterAllocationAccessor(); var result = await sut.LoadSiteSpecificAmounts((new Faker()).Random.AlphaNumeric(10), new[] { siteSpecificAmount }); result.Should().BeTrue(); using (var db = new WaDEContext(Configuration.GetConfiguration())) { var dbSiteVariableAmount = await db.SiteVariableAmountsFact.SingleAsync(); dbSiteVariableAmount.OrganizationId.Should().Be(organization.OrganizationId); dbSiteVariableAmount.SiteId.Should().Be(site.SiteId); dbSiteVariableAmount.VariableSpecificId.Should().Be(variable.VariableSpecificId); dbSiteVariableAmount.WaterSourceId.Should().Be(waterSource.WaterSourceId); dbSiteVariableAmount.MethodId.Should().Be(method.MethodId); dbSiteVariableAmount.PrimaryUseCategoryCV.Should().Be(primaryUseCategory.Name); dbSiteVariableAmount.ReportYearCv.Should().Be(reportYear.Name); dbSiteVariableAmount.PopulationServed.Should().Be(long.Parse(siteSpecificAmount.PopulationServed)); dbSiteVariableAmount.CommunityWaterSupplySystem.Should().Be(siteSpecificAmount.CommunityWaterSupplySystem); dbSiteVariableAmount.CustomerTypeCv.Should().Be(customerType.Name); dbSiteVariableAmount.SDWISIdentifierCv.Should().Be(sdwisIdentifier.Name); db.ImportErrors.Should().HaveCount(0); } }