public override IQueryable <Department> Apply(IQueryable <Department> qry) { if (Ids?.Length > 0) { qry = qry.Where(x => Ids.Contains(x.Id)); } if (Id != null) { qry = qry.Where(x => x.Id == Id); } if (!string.IsNullOrEmpty(Name)) { qry = qry.Where(a => a.Name == Name); } if (!string.IsNullOrEmpty(Term)) { qry = qry.Where(a => a.Code.Contains(Term) || a.Name.Contains(Term)); } if (Deleted != null) { qry = qry.Where(x => x.Deleted == Deleted); } return(qry); }
/// <summary> /// 创建查询对象 /// </summary> /// <returns>返回查询对象</returns> public override IQuery CreateQuery() { IQuery query = base.CreateQuery() ?? QueryManager.Create <PermissionGroupEntity>(this); if (LevelOne) { query.And <PermissionGroupEntity>(c => c.Parent <= 0); } if (!Ids.IsNullOrEmpty()) { query.And <PermissionGroupEntity>(c => Ids.Contains(c.Id)); } if (!ExcludeIds.IsNullOrEmpty()) { query.And <PermissionGroupEntity>(c => !ExcludeIds.Contains(c.Id)); } if (!string.IsNullOrWhiteSpace(Name)) { query.And <PermissionGroupEntity>(c => c.Name == Name); } if (Sort.HasValue) { query.And <PermissionGroupEntity>(c => c.Sort == Sort.Value); } if (Parent.HasValue) { query.And <PermissionGroupEntity>(c => c.Parent == Parent.Value); } if (!string.IsNullOrWhiteSpace(Remark)) { query.And <PermissionGroupEntity>(c => c.Remark == Remark); } return(query); }
public IQueryable <Planet> Filter(IQueryable <Planet> planetQuery) { if (!string.IsNullOrEmpty(ToSearch)) { if (!PerfectMatch) { ToSearch = new string("%" + ToSearch + "%"); } planetQuery = planetQuery.Where(planet => EF.Functions.Like(planet.Name, ToSearch)); } if (Ids != null && Ids.Count != 0) { planetQuery = planetQuery.Where(planet => Ids.Contains(planet.Id)); } if (SystemId != Guid.Empty) { planetQuery = planetQuery.Where(t => t.SolarSystemId.Equals(SystemId)); } if (ShuttleId != Guid.Empty) { planetQuery = planetQuery.Where(t => t.ShuttleId.Equals(ShuttleId)); } return(planetQuery); }
public void Add(Field field) { if (Ids.Contains(field.Id)) { return; } _passwordFields = _usernameFields = null; Ids.Add(field.Id); Fields.Add(field); AutofillIds.Add(field.AutofillId); IdToFieldMap.Add(field.Id, field); if (field.Hints != null) { foreach (var hint in field.Hints) { Hints.Add(hint); if (field.Focused) { FocusedHints.Add(hint); } if (!HintToFieldsMap.ContainsKey(hint)) { HintToFieldsMap.Add(hint, new List <Field>()); } HintToFieldsMap[hint].Add(field); } } }
public IQueryable <Explorer> Filter(IQueryable <Explorer> explorerQuery) { if (!string.IsNullOrEmpty(ToSearch)) { if (!PerfectMatch) { ToSearch = new string("%" + ToSearch + "%"); } explorerQuery = explorerQuery.Where(humanCaptain => EF.Functions.Like(humanCaptain.Name, ToSearch)); } if (Ids != null && Ids.Count != 0) { explorerQuery = explorerQuery.Where(humanCaptain => Ids.Contains(humanCaptain.Id) || Ids.Contains(humanCaptain.TeamOfExplorersId)); } if (TeamId != Guid.Empty) { explorerQuery = explorerQuery.Where(t => t.TeamOfExplorersId.Equals(TeamId)); } return(explorerQuery); }
private void AddInternal(TItem item) { if (item == null) { return; } if (ModelRegistry.IsManagedModel(item) && !ModelRegistry.IsManagedBy(Session, item)) { var id = ModelRegistry.GetId(item); throw new UnmanagedModelException(item.GetType(), id); } var itemId = ModelRegistry.GetOrCreateId(item); Session.Cache.Update(itemId, item); if (Ids.Contains(itemId)) { return; } Ids.Add(itemId); IsModified = true; }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var jObject = JObject.Load(reader); var typeName = jObject["type"]?.Value <string>() ?? jObject["@type"]?.Value <string>(); if (typeName == null) { // Get value of this objectType's "Type" JsonProperty(Required) var typeJsonPropertyRequiredValue = objectType.GetRuntimeProperty("Type") .CustomAttributes.Where(a => a.AttributeType == typeof(JsonPropertyAttribute)).FirstOrDefault()? .NamedArguments.Where(a => a.TypedValue.ArgumentType == typeof(Required)).FirstOrDefault() .TypedValue.Value.ToString(); // If this objectType does not require "Type" attribute, use the objectType's XML "TypeName" attribute if (typeJsonPropertyRequiredValue == "0") { typeName = objectType .GetRuntimeFields().Where(x => x.Name == "TypeName").FirstOrDefault()? .GetValue("TypeName").ToString(); } else { throw new AdaptiveSerializationException("Required property 'type' not found on adaptive card element"); } } if (TypedElementTypes.Value.TryGetValue(typeName, out var type)) { if (jObject.Value <string>("id") == null) { if (typeof(AdaptiveInput).GetTypeInfo().IsAssignableFrom(type.GetTypeInfo())) { throw new AdaptiveSerializationException($"Required property 'id' not found on '{typeName}'"); } } else { string objectId = jObject.Value <string>("id"); if (Ids.Contains(objectId)) { throw new AdaptiveSerializationException($"Duplicate 'id' found: '{objectId}'"); } else { Ids.Add(objectId); } } var result = (AdaptiveTypedElement)Activator.CreateInstance(type); serializer.Populate(jObject.CreateReader(), result); HandleAdditionalProperties(result); return(result); } Warnings.Add(new AdaptiveWarning(-1, $"Unknown element '{typeName}'")); return(null); }
public override object ExecuteCommand(InCourseRequest inCourseRequest) { var request = (from d in context.PortfoliosUsuario where Ids.Contains(d.IdPortfolioUsuario) select d).ToList(); this.context.RemoveRange(request); return(null); }
/// <summary> /// 若不填Id則取全部, 填了取部分 /// </summary> /// <param name="db"></param> /// <param name="Ids"></param> /// <returns></returns> private IQueryable <TodoItem> Get(TodoContext db, params Guid[] Ids) { var query = db.TodoItems.AsQueryable(); if (Ids.Count() > 0) { query = query.Where(item => Ids.Contains(item.Id)); } return(query); }
public override Expression <Func <WorkflowDefinition, bool> > ToExpression() { Expression <Func <WorkflowDefinition, bool> > predicate = x => Ids.Contains(x.DefinitionId); if (VersionOptions != null) { predicate = predicate.WithVersion(VersionOptions); } return(predicate); }
public bool Contains(TItem item) { if (item == null) { return(false); } Initialize(); return(Ids.Contains(ModelRegistry.GetId(item))); }
internal Func <Product, bool> GetFuncPredicate() { return((Product p) => (Ids != null && Ids.Any() ? Ids.Contains(p.Id) : true) && (MaxCount != null ? p.CountInStock < MaxCount : true) && (MinCount != null ? p.CountInStock > MinCount : true) && (UnitId != null ? p.UnitId == UnitId : true) && (MinWeight != null ? p.Weight > MinWeight : true) && (MaxWeight != null ? p.Weight < MaxWeight : true) && (ManufactureCountryId != null ? p.ManufactureCountryId == ManufactureCountryId : true) && (Name != null ? p.Name.Contains(Name, StringComparison.OrdinalIgnoreCase) : true)); }
protected override void AddFilters() { FilterIfHasValue(Ids, session => Ids.Contains(session.Id)); FilterIfHasValue(VariantIds, session => VariantIds.Contains(session.TestSessionId)); FilterIfHasValue(VariantId, session => session.TestVariantId == VariantId.Value); FilterIfHasValue(Id, session => session.Id == Id.Value); FilterIfHasValue(State, session => session.State == State); FilterIfHasValue(StudentId, session => session.StudentId == StudentId.Value); FilterIfHasValue(ExceptTestSessionState, session => session.TestSession.State != ExceptTestSessionState); FilterIfHasValue(ExcludedStates, session => !ExcludedStates.Contains(session.State)); FilterIfHasValue(TestSessionId, session => session.TestSessionId == TestSessionId.Value); FilterIfHasValue(MoreOrGreaterThanShouldEndAt, session => session.ShouldEndAt <= MoreOrGreaterThanShouldEndAt); }
/// <summary> /// 搜索后运行的函数,继承的类如果需要在搜索结束后进行其他操作,可重载这个函数 /// </summary> public virtual void AfterDoSearcher() { if (SearcherMode == ListVMSearchModeEnum.Selector && Ids != null && Ids.Count > 0 && EntityList != null && EntityList.Count > 0) { foreach (var item in EntityList) { if (Ids.Contains(item.ID)) { item.Checked = true; } } } }
public Chief(string firstName, string secondName, string departamentName, long id, byte age) { FirstName = firstName; SecondName = secondName; DepartamentName = departamentName; if (Ids.Contains(id)) { id = defIndexId; } Id = id; Age = age; defIndexId++; }
public Intern(string firstName, string secondName, string departamentName, long id, byte age, uint salary) { FirstName = firstName; SecondName = secondName; DepartamentName = departamentName; if (Ids.Contains(id)) { id = defIndexId; } Id = id; Age = age; CalculateSalary(salary); defIndexId++; }
public Staffer(string firstName, string secondName, string departamentName, long id, byte age, int workHours) { FirstName = firstName; SecondName = secondName; DepartamentName = departamentName; if (Ids.Contains(id)) { id = defIndexId; } Id = id; Age = age; CalculateSalary(workHours); defIndexId++; }
public IQueryable <RoomJob> Filter(IQueryable <RoomJob> filterQuery) { if (!string.IsNullOrEmpty(SearchTerm)) { return(Guid.TryParse(SearchTerm, out var roomId) ? filterQuery.Where(t => t.Id == roomId) : filterQuery.Where(t => CheckContains(t))); } if (Ids.Count > 0) { filterQuery = filterQuery.Where(t => Ids.Contains(t.Id)); } return(filterQuery); }
public IQueryable <RoomWallObject> Filter(IQueryable <RoomWallObject> filterQuery) { if (!string.IsNullOrEmpty(SearchTerm)) { return(Guid.TryParse(SearchTerm, out var roomId) ? filterQuery.Where(t => t.Id == roomId) : filterQuery.Where(t => t.Type.ToString() == SearchTerm)); } if (Ids.Count > 0) { filterQuery = filterQuery.Where(t => Ids.Contains(t.Id)); } return(filterQuery); }
public override Expression <Func <TSelector, bool> > ToExpresion() { var expresion = base.ToExpresion(); if (Ids != null) { expresion = expresion.And(e => Ids.Contains(e.Id)); } if (Text != null) { expresion = expresion.And(x => EF.Functions.Like(x.Text, $"%{Text}%")); } return(expresion); }
/// <summary> /// 设定批量模式下的搜索语句,继承的类应重载这个函数来指定自己批量模式的搜索语句,如果不指定则默认使用Ids.Contains(x.Id)来代替搜索语句中的Where条件 /// </summary> /// <returns>搜索语句</returns> public virtual IOrderedQueryable <TModel> GetBatchQuery() { var baseQuery = GetSearchQuery(); if (ReplaceWhere == null) { WhereReplaceModifier mod = new WhereReplaceModifier(x => Ids.Contains(x.ID)); var newExp = mod.Modify(baseQuery.Expression); var newQuery = baseQuery.Provider.CreateQuery <TModel>(newExp) as IOrderedQueryable <TModel>; return(newQuery); } else { return(baseQuery); } }
public IQueryable <SolarSystem> Filter(IQueryable <SolarSystem> solarSystemQuery) { if (!string.IsNullOrEmpty(ToSearch)) { if (!PerfectMatch) { ToSearch = new string("%" + ToSearch + "%"); } solarSystemQuery = solarSystemQuery.Where(system => EF.Functions.Like(system.Name, ToSearch)); } if (Ids != null && Ids.Count != 0) { solarSystemQuery = solarSystemQuery.Where(system => Ids.Contains(system.Id)); } return(solarSystemQuery); }
public IQueryable <Shuttle> Filter(IQueryable <Shuttle> shuttleQuery) { if (!string.IsNullOrEmpty(ToSearch)) { if (!PerfectMatch) { ToSearch = new string("%" + ToSearch + "%"); } shuttleQuery = shuttleQuery.Where(shuttle => EF.Functions.Like(shuttle.Name, ToSearch)); } if (Ids != null && Ids.Count != 0) { shuttleQuery = shuttleQuery.Where(shuttle => Ids.Contains(shuttle.Id)); } return(shuttleQuery); }
public Func <WorkItem, bool> GetPredicate() { return(x => { bool result = true; if (Ids != null) { result = Ids.Contains(x.Id); } if (Statuses != null) { result = result && Statuses.Contains(x.Status); } if (ExecutionTypes != null) { result = result && ExecutionTypes.Contains(x.ExecutionType); } return result; }); }
public int AllocateId() { while (true) { if (_lastAssignedId < int.MaxValue) { _lastAssignedId++; } else { _lastAssignedId = 0; } if (!Ids.Contains(_lastAssignedId)) { Ids.Add(_lastAssignedId); return(_lastAssignedId); } } }
public IQueryable <TeamOfExplorers> Filter(IQueryable <TeamOfExplorers> teamOfExplorersQuery) { if (!string.IsNullOrEmpty(ToSearch)) { if (!PerfectMatch) { ToSearch = new string("%" + ToSearch + "%"); } teamOfExplorersQuery = teamOfExplorersQuery.Where(t => EF.Functions.Like(t.Name, ToSearch)); } if (Ids != null && Ids.Count != 0) { teamOfExplorersQuery = teamOfExplorersQuery.Where(t => Ids.Contains(t.Id)); } if (ShuttleGuid != Guid.Empty) { teamOfExplorersQuery = teamOfExplorersQuery.Where(t => t.ShuttleId.Equals(ShuttleGuid)); } return(teamOfExplorersQuery); }
public virtual IQueryable <T> ApplyFilter(IQueryable <T> query) { query = query.Where(Query); if (Ids.Count > 0) { query = query.Where(d => Ids.Contains(d.Id)); } if (_isOwnedByOrganization && OrganizationIds.Count > 0) { query = query.Where(d => OrganizationIds.Contains(((IOwnedByOrganization)d).OrganizationId)); } if (_isOwnedByProject && ProjectIds.Count > 0) { query = query.Where(d => ProjectIds.Contains(((IOwnedByProject)d).ProjectId)); } if (_isOwnedByStack && StackIds.Count > 0) { query = query.Where(d => StackIds.Contains(((IOwnedByStack)d).StackId)); } return(query); }
private static void ArchivedCustomerOrdersWithoutCustomerOrderParts() { IDbTransactionData dbTransactionData = ZppConfiguration.CacheManager.GetDbTransactionData(); Ids customerOrderIds = new Ids(); foreach (var demand in dbTransactionData.CustomerOrderPartGetAll()) { CustomerOrderPart customerOrderPart = (CustomerOrderPart)demand; customerOrderIds.Add(customerOrderPart.GetCustomerOrderId()); } foreach (var customerOrder in dbTransactionData.CustomerOrderGetAll()) { bool customerOrderHasNoCustomerOrderPart = customerOrderIds.Contains(customerOrder.GetId()) == false; if (customerOrderHasNoCustomerOrderPart) { ArchiveCustomerOrder(customerOrder.GetId()); } } }
public IQueryable <Robot> Filter(IQueryable <Robot> robotQuery) { if (!string.IsNullOrEmpty(ToSearch)) { if (!PerfectMatch) { ToSearch = new string("%" + ToSearch + "%"); } robotQuery = robotQuery.Where(robot => EF.Functions.Like(robot.Name, ToSearch)); } if (Ids != null && Ids.Count != 0) { robotQuery = robotQuery.Where(robot => Ids.Contains(robot.Id)); } if (TeamId != Guid.Empty) { robotQuery = robotQuery.Where(t => t.TeamOfExplorersId.Equals(TeamId)); } return(robotQuery); }
private static void ArchivedPurchaseOrdersWithoutPurchaseOrderParts() { IDbTransactionData dbTransactionData = ZppConfiguration.CacheManager.GetDbTransactionData(); Ids purchaseOrderIds = new Ids(); foreach (var demand in dbTransactionData.PurchaseOrderPartGetAll()) { PurchaseOrderPart purchaseOrderPart = (PurchaseOrderPart)demand; purchaseOrderIds.Add(purchaseOrderPart.GetPurchaseOrderId()); } foreach (var purchaseOrder in dbTransactionData.PurchaseOrderGetAll()) { bool purchaseOrderHasNoPurchaseOrderParts = purchaseOrderIds.Contains(purchaseOrder.GetId()) == false; if (purchaseOrderHasNoPurchaseOrderParts) { ArchivePurchaseOrder(purchaseOrder); } } }