public async Task <ProjectSubSearchModel> GetProjectByHolidayIdAsync(int holidayId) { var holiday = await _context.Holidays.Include(h => h.Project) .Where(h => h.HolidayId == holidayId).FirstOrDefaultAsync(); var project = holiday == null ? null : holiday.Project; var projectSearch = ProjectOperator.SetProjectSubSearchModel(project); return(projectSearch); }
public async Task <ProjectSubSearchModel> GetProjectByGroupIdAsync(int groupId) { var group = await _context.Groups .Include(g => g.Project) .Where(g => g.GroupId == groupId).FirstOrDefaultAsync(); var project = group == null ? null : group.Project; var projectSearch = ProjectOperator.SetProjectSubSearchModel(project); return(projectSearch); }
public ProjectSearchModel FindById(int projectId) { var result = _context.Projects.Where(v => v.ProjectId == projectId); result = (IQueryable <Project>)ExpandOperator.ExpandRelatedEntities <Project>(result); var project = result.FirstOrDefault(); var projectSearch = ProjectOperator.SetProjectSearchModelCascade(project); return(projectSearch); }
public async Task <ProjectSubSearchModel> GetProjectByLocationIdAsync(int locationId) { var location = await _context.Locations .Include(l => l.Project) .Where(l => l.LocationId == locationId).FirstOrDefaultAsync(); var project = location == null ? null : location.Project; var projectSearch = ProjectOperator.SetProjectSubSearchModel(project); return(projectSearch); }
/// <summary> /// Projects a single bindable object into another bindable object, using a lambda to select the new /// type of object. /// </summary> /// <typeparam name="TSource">The type of the source.</typeparam> /// <typeparam name="TResult">The type of the result.</typeparam> /// <param name="source">The source colection.</param> /// <param name="projector">The projector function used to turn the source type into the result type.</param> /// <param name="dependencyAnalysisMode">The dependency analysis mode.</param> /// <returns> /// An object created by the <paramref name="projector"/>. If the source value changes, the item will be projected again. /// </returns> public static IBindable <TResult> Project <TSource, TResult>(this IBindable <TSource> source, Expression <Func <TSource, TResult> > projector, DependencyDiscovery dependencyAnalysisMode) { source.ShouldNotBeNull("source"); projector.ShouldNotBeNull("projector"); var result = new ProjectOperator <TSource, TResult>(source, projector.Compile(), source.Dispatcher); if (dependencyAnalysisMode == DependencyDiscovery.Enabled) { return(result.DependsOnExpression(projector.Body, projector.Parameters[0])); } return(result); }
public async Task <ProjectSubSearchModel> GetProjectBySceneIdAsync(int sceneId) { var scenes = await _context.Scenes .Include(s => s.Project).Where(s => s.SceneId == sceneId) .FirstOrDefaultAsync(); var project = scenes == null ? null : scenes.Project; var projectSearch = ProjectOperator.SetProjectSubSearchModel(project); return(projectSearch); }
public async Task <IEnumerable <ProjectSubSearchModel> > GetProjectsByCustomerIdAsync(int customerId) { var queryData = _context.Projects .Where(v => v.CustomerId == customerId); var result = QueryOperate <Project> .Execute(queryData); var projects = await result.ToListAsync(); var projectSearch = ProjectOperator.SetProjectSubSearchModel(projects); return(projectSearch); }
async public Task <Project> SearchProjectAsync(string projectname) { using (ProjectOperator projectOperator = new ProjectOperator(_hostname, _settings)) { try { return(await projectOperator.SearchProjectAsync(projectname)); } catch (OperatorException) { return(null); } } }
async public Task <IEnumerable <User> > GetUsersAsync() { using (ProjectOperator projectOperator = new ProjectOperator(_projectKey.HostName, _settings)) { try { return(await projectOperator.GetUsersAsync(_projectKey.ProjectName)); } catch (OperatorException) { return(null); } } }
public async Task <IEnumerable <ProjectSearchModel> > GetAllAsync() { var queryData = from P in _context.Projects select P; var result = QueryOperate <Project> .Execute(queryData); result = (IQueryable <Project>)ExpandOperator.ExpandRelatedEntities <Project>(result); //以下执行完后才会去数据库中查询 var projects = await result.ToListAsync(); var projectSearch = ProjectOperator.SetProjectSearchModelCascade(projects); return(projectSearch); }
/// <summary> /// Run the operation adding MongoDB operators to the pipeline /// </summary> /// <param name="LastResult"></param> /// <returns></returns> public override AlgebraOperatorResult Run(IModelMap inMap, IEnumerable <ProjectArgument> inAttributesToProject = null) { if (inMap is VirtualMap) { Map = inMap; RuleMap = inMap; } // Store operators to run List <MongoDBOperator> OperatorsToExecute = new List <MongoDBOperator>(); // All we need to do is find the correct map for each attribute // Argument already provides which expression to apply Dictionary <string, ProjectExpression> AttributesAndExpressions = new Dictionary <string, ProjectExpression>(); // Iterate all arguments foreach (ProjectArgument Argument in Arguments) { // Skip if Argument.Attribute is null if (Argument.Attribute == null) { continue; } // Each argument provides all necessary data string AttributeMap = Map.GetRuleValue(Argument.ParentEntity.Alias ?? Argument.ParentEntity.GetName(), Argument.Attribute.Name); if (string.IsNullOrWhiteSpace(AttributeMap)) { continue; } // Add to attribute list // Including quotation marks to prevent trouble with dot notation AttributesAndExpressions.Add($"\"{AttributeMap}\"", Argument.Expression); } // Only add projection if AttributesAndExpressions have content if (AttributesAndExpressions.Count > 0) { // Create project operator ProjectOperator ProjectOp = new ProjectOperator(AttributesAndExpressions); // Add to execution list // TODO: This process can be simplified to a single ProjectOperator OperatorsToExecute.Add(ProjectOp); } // Return operators return(new AlgebraOperatorResult(OperatorsToExecute)); }