public async Task <IActionResult> Index() { IIncludableQueryable <Models.Task, Project> vPMDBContext = _context.Task.Include(t => t.Project); List <Models.Task> tasks = await vPMDBContext.ToListAsync(); return(View(tasks)); }
public IIncludableQueryable <TEntity, TProperty> ThenInclude <TEntity, TPreviousProperty, TProperty>( IIncludableQueryable <TEntity, TPreviousProperty> source, Expression <Func <TPreviousProperty, TProperty> > navigationPropertyPath) where TEntity : class { return(new IncludableQueryable <TEntity, TProperty>(((Microsoft.EntityFrameworkCore.Query.IIncludableQueryable <TEntity, TPreviousProperty>)source).ThenInclude(navigationPropertyPath))); }
private void AddMissingJoinedOnDates(IIncludableQueryable <Member, ICollection <Change> > members, ILogger log) { this.ChangeTracker.AutoDetectChangesEnabled = false; foreach (var m in members.ToArray().Where(x => x.JoinedOn == null && !x.HasLeft && x.Payments.Count() > 0).ToArray()) { var ep = m.Payments.OrderBy(x => x.DueDate).FirstOrDefault().DueDate; if (ep != null) { m.JoinedOn = ep; var cr = new Change { Date = DateTimeOffset.Now, MadeBy = "System", Member = m, Description = $"Joined on date {ep.ToDefault()} taken from payment record" }; m.Changes.Add(cr); //this.SaveChanges(); log.Information($"set member {m.Name} joining date to {ep.ToDefault()}"); } } this.ChangeTracker.DetectChanges(); this.SaveChanges(); this.ChangeTracker.AutoDetectChangesEnabled = true; }
public static IIncludableQueryable <TClass> Include <TClass, TProperty>( this IIncludableQueryable <TClass> includable, Expression <Func <TClass, TProperty> > expr, Expression <Func <TProperty, bool> > propertyFilter = null) where TClass : class where TProperty : class => includable.AddExpression(expr, propertyFilter);
private void UpdatePaymentStatus(IIncludableQueryable <Member, ICollection <Change> > members, QParaOptions options, ILogger log) { this.ChangeTracker.AutoDetectChangesEnabled = false; var selectedMembers = members .Where(x => x.SubscriptionPeriod != SubscriptionPeriod.Life && (x.SubscriptionType == SubscriptionType.Standard || x.SubscriptionType == SubscriptionType.Concession)) ; var notSelectedMembers = members.Except(selectedMembers).Where(x => !x.GetIsPaid(options) /*!x.IsPaid*/); foreach (var m in notSelectedMembers.ToArray()) { if (m.AmountDue != 0 || m.AmountReceived != 0) { m.AmountDue = m.AmountReceived = 0; log.Information($"{m.FirstName} {m.LastName} due and received amounts reset (to 0)"); //SaveChanges(); } } var subscriptionYear = options.GetSubscriptionYear(DateTimeOffset.UtcNow); foreach (var m in selectedMembers.ToArray()) { m.UpdatePaymentRecords(options, true); //SaveChanges(); } ChangeTracker.DetectChanges(); SaveChanges(); this.ChangeTracker.AutoDetectChangesEnabled = true; }
public IActionResult Filter(int?company, string name) { IIncludableQueryable <MetanitExampleCoreMVC.Models.User, Company> users = dbUsers.Users.Include(p => p.Company); IQueryable <MetanitExampleCoreMVC.Models.User> usersResult = null; if (company != null && company != 0) { usersResult = users.Where(p => p.CompanyId == company); } else { usersResult = users; } if (!String.IsNullOrEmpty(name)) { usersResult = usersResult.Where(p => p.Name.Contains(name)); } List <Company> companies = dbUsers.Companies.ToList(); // устанавливаем начальный элемент, который позволит выбрать всех companies.Insert(0, new Company { Name = "Все", Id = 0 }); UsersListViewModel viewModel = new UsersListViewModel { Users = usersResult?.ToList(), Companies = new SelectList(companies, "Id", "Name"), Name = name }; return(View(viewModel)); }
private void SearchByPrice(ref IIncludableQueryable <Product, ICollection <Color> > products, double?MinPrice, double?MaxPrice) { if (!products.Any()) { return; } if (MinPrice == null && MaxPrice != null) { products = products.Where(c => c.price <= MaxPrice) .Include(s => s.Sizes) .Include(c => c.Colors); } else if (MinPrice != null && MaxPrice == null) { products = products.Where(c => c.price >= MinPrice) .Include(s => s.Sizes) .Include(c => c.Colors); } else if (MinPrice != null && MaxPrice != null) { products = products.Where(c => c.price >= MinPrice && c.price <= MaxPrice) .Include(s => s.Sizes) .Include(c => c.Colors); } }
public static IIncludableQueryable<User, UserBuild> ThenIncludeEverything(this IIncludableQueryable<User, ICollection<User.UserGeneratedBuildOrder>> userBuilds) { return userBuilds .Include(x => x.UserGeneratedBuildOrders) .ThenInclude(x => x.UserGeneratedBuild) .ThenInclude(x => x.Processor) .Include(x => x.UserGeneratedBuildOrders) .ThenInclude(x => x.UserGeneratedBuild) .ThenInclude(x => x.Motherboard) .Include(x => x.UserGeneratedBuildOrders) .ThenInclude(x => x.UserGeneratedBuild) .ThenInclude(x => x.Memory) .Include(x => x.UserGeneratedBuildOrders) .ThenInclude(x => x.UserGeneratedBuild) .ThenInclude(x => x.GraphicsCard) .Include(x => x.UserGeneratedBuildOrders) .ThenInclude(x => x.UserGeneratedBuild) .ThenInclude(x => x.Storage) .Include(x => x.UserGeneratedBuildOrders) .ThenInclude(x => x.UserGeneratedBuild) .ThenInclude(x => x.PowerSupply) .Include(x => x.UserGeneratedBuildOrders) .ThenInclude(x => x.UserGeneratedBuild) .ThenInclude(x => x.Case) .Include(x => x.UserGeneratedBuildOrders) .ThenInclude(x => x.UserGeneratedBuild); }
public async Task <IActionResult> Index() { var user = await _userManager.GetUserAsync(HttpContext.User); var organizationsManagedByUser = _context.OrganizationAdministratorUsers .Where(x => x.User == user) .Select(x => x.OrganizationId) .ToList(); IIncludableQueryable <Opportunity, Organization> opportunitiesQueryable = _context.Opportunities .Include(o => o.Category) .Include(o => o.CreatedBy) .Include(o => o.Organization); List <Opportunity> opportunities = opportunitiesQueryable .Where(x => organizationsManagedByUser.Contains(x.Organization.Id)) .OrderByDescending(x => x.Id) .ToList(); return(View(opportunities .Select(opportunity => new OpportunityIndexViewModel() { Id = opportunity.Id, CreatedDateTime = opportunity.CreatedDateTime, Name = opportunity.Name, Category = opportunity.Category?.Name, OpportunityType = opportunity.OpportunityType, IsArchived = opportunity.IsArchived }) .ToList())); }
public BusinessIncludableQuery( BusinessQuery <TCollection, TReadOnlyCollection, TObject, TEntry, TKey> businessQuery, IIncludableQueryable <TEntry, TProperty> query ) : base(businessQuery.BusinessQueryContext, query) { _includableQueryable = query; }
IncludeAvailabilityRestrictions(this IIncludableQueryable <ContractAccommodationRelation, SeasonRange> queryable, AvailabilityRequest availabilityRequest) => queryable.Include(relation => relation.Accommodation) .ThenInclude(accommodation => accommodation.Rooms) .ThenInclude(room => room.AvailabilityRestrictions.Where(availabilityRestrictions => availabilityRequest.CheckInDate <= availabilityRestrictions.ToDate && availabilityRestrictions.FromDate <= availabilityRequest.CheckOutDate));
public RecruiterService(DatabaseContext databaseContext) { _databaseContext = databaseContext; _recruitersIncludableGetQuery = _databaseContext.Recruiters .Include(x => x.Positions) .Include(x => x.ConversationData); }
public static IIncludableQueryable <TEntity, TProperty> ThenIncluding <TEntity, TPreviousProperty, TProperty>( this IIncludableQueryable <TEntity, IEnumerable <TPreviousProperty> > source, Expression <Func <TPreviousProperty, TProperty> > navigationPropertyPath) where TEntity : class { return(System.Data.Entity.Include.QueryInclude.ThenInclude(source, navigationPropertyPath)); }
public async Task <IActionResult> Index() { ApplicationUser user = await GetCurrentUser(); bool isAdmin = await IsAdmin(user); IIncludableQueryable <Opportunity, Organization> opportunitiesQueryable = _context.Opportunities .Include(o => o.Category) .Include(o => o.Community) .Include(o => o.Organization); List <Opportunity> opportunities; if (isAdmin) { opportunities = await opportunitiesQueryable .ToListAsync(); } else { opportunities = await opportunitiesQueryable .Where(o => o.CreatedByUserId == user.Id) .ToListAsync(); } return(View(opportunities)); }
// GET: ProjectUsers public async Task <IActionResult> Index( ) { IIncludableQueryable <ProjectUser, HeimdallUser> applicationDbContext = this.context.ProjectUsers.Include(p => p.Project).Include(p => p.User); return(this.View(await applicationDbContext.ToListAsync( ).ConfigureAwait(false))); }
public static IIncludableQueryable <TEntity, TProperty> ThenInclude <TEntity, TPreviousProperty, TProperty>( this IIncludableQueryable <TEntity, IEnumerable <TPreviousProperty> > source, Expression <Func <TPreviousProperty, TProperty> > navigationPropertyPath) where TEntity : class { return(QueryableAdapter.ThenInclude(source, navigationPropertyPath)); }
private void SearchByCustomer(ref IIncludableQueryable <Order, Address> orders, int?customerId) { if (!orders.Any() || customerId == null) { return; } orders = orders.Where(o => o.customerId == customerId).Include(o => o.Address); }
public void SearchByZip(ref IIncludableQueryable <Order, Address> orders, string zip) { if (!orders.Any() || string.IsNullOrEmpty(zip)) { return; } orders = orders.Where(o => o.zip.Contains(zip.Trim())).Include(o => o.Address); }
public void SearchByCountry(ref IIncludableQueryable <Order, Address> orders, string country) { if (!orders.Any() || string.IsNullOrEmpty(country)) { return; } orders = orders.Where(o => o.country.Contains(country.Trim().ToLower())).Include(o => o.Address); }
public void ShouldGetAllOfTheCarsWithMakes() { IIncludableQueryable <Car, Make?> query = Context.Cars.Include(c => c.MakeNavigation); var qs = query.ToQueryString(); var cars = query.ToList(); Assert.Equal(9, cars.Count); }
/// <summary> /// /// </summary> /// <param name="context"></param> /// <param name="guid"></param> /// <returns></returns> public static async Task <PatientJournal> GetPatientJournalById(this AerendeContext context, Guid guid) { IIncludableQueryable <PatientJournal, Adress> patientJournal = context.GetChildrenInQuery(); var singelPatientJournal = patientJournal.SingleOrDefaultAsync(x => x.Id == guid); return(await singelPatientJournal); }
public Task <Meal> FindAsync(int id) { var meal = new Meal(); IIncludableQueryable <Meal, FoodItem> wackyEntity = context.Meals.Include(x => x.MealFoodItems).ThenInclude(x => x.FoodItems); throw new NotImplementedException(); }
public static IQueryable <TEntity> OptionalThenInclude <TEntity, TPreviousProperty, TProperty>( [NotNull] this IIncludableQueryable <TEntity, TPreviousProperty> source, [NotNull] Expression <Func <TPreviousProperty, TProperty> > navigationPropertyPath, bool performInclude) where TEntity : class { return(!performInclude ? (IQueryable <TEntity>)source : source.ThenInclude(navigationPropertyPath)); }
// GET: TicketAttachments public async Task <IActionResult> Index( ) { IIncludableQueryable <TicketAttachment, HeimdallUser> applicationDbContext = this.context.TicketAttachments .Include(t => t.Ticket) .Include(t => t.User); return(this.View(await applicationDbContext.ToListAsync( ).ConfigureAwait(false))); }
public void SearchByOrderNumber(ref IIncludableQueryable <Order, Address> orders, string orderNumber) { if (!orders.Any() || string.IsNullOrEmpty(orderNumber)) { return; } orders = orders.Where(o => o.orderNumber.ToLower().Contains(orderNumber.Trim().ToLower())) .Include(o => o.Address); }
private IIncludableQueryable <Event, object> GetInclude(IQueryable <Event> e) { IIncludableQueryable <Event, object> include = e .Include(e => e.ActionDevice) .Include(e => e.EventConditions) .ThenInclude(ec => ec.DataPoint); return(include); }
public static IIncludableQueryable <TEntity, TProperty> ThenIncludeMany <TEntity, TPreviousProperty, TProperty>( [NotNull] this IIncludableQueryable <TEntity, TPreviousProperty> source, Expression <Func <TPreviousProperty, IEnumerable <TProperty> > > navigationPropertyPath) where TEntity : class { return(source .ThenInclude(navigationPropertyPath) .ThenInclude <TEntity, TProperty, TProperty>(r => r)); }
public static IIncludableJoin <TEntity, TProperty> ThenIncludeJoin <TEntity, TPreviousProperty, TProperty>( this IIncludableJoin <TEntity, TPreviousProperty> query, Expression <Func <TPreviousProperty, TProperty> > propToExpand) where TEntity : class { IIncludableQueryable <TEntity, TPreviousProperty> queryable = ((IncludableJoin <TEntity, TPreviousProperty>)query).GetQuery(); return(new IncludableJoin <TEntity, TProperty>(queryable.ThenInclude(propToExpand))); }
public static IQueryable <T> If <T, P>( this IIncludableQueryable <T, IEnumerable <P> > source, bool condition, Func <IIncludableQueryable <T, IEnumerable <P> >, IQueryable <T> > transform ) where T : class { return(condition ? transform(source) : source); }
public void SearchByState(ref IIncludableQueryable <Order, Address> orders, string state) { if (!orders.Any() || string.IsNullOrEmpty(state)) { return; } orders = orders.Where(o => o.state.Contains(state.Trim().ToLower())) .Include(o => o.Address); }