public override FilterDefinition <MongoContentEntity> Visit(UnaryOperatorNode nodeIn) { if (nodeIn.OperatorKind == UnaryOperatorKind.Not) { return(Filter.Not(nodeIn.Operand.Accept(this))); } throw new NotSupportedException(); }
public void NotEq_TopLevel() { var fb = new FilterDefinitionBuilder <BasicDocument>(); Find(fb.Not(fb.Eq(x => x.Name, _item.Name))) .ShouldHaveOneResultMatching(_item2); }
public static FilterDefinition <TDocument> NotDeactivated <TDocument, TItem>(FilterDefinitionBuilder <TDocument> builder, Expression <Func <TDocument, IEnumerable <TItem> > > acessor, DateTime?dateTime = null) where TItem : IActivationAware { var twoBuilder = new FilterDefinitionBuilder <TItem>(); if (!dateTime.HasValue) { dateTime = DateTime.UtcNow; } return(builder.Or ( builder.Not ( builder.ElemMatch ( acessor, twoBuilder.Exists ( t => t.DeactivationDate ) ) ), builder.ElemMatch ( acessor, twoBuilder.Gt ( t => t.DeactivationDate, dateTime.Value ) ) )); }
public async System.Threading.Tasks.Task <bool> IsUnique(string login, long?id = null, long?teamId = null, string?teamName = null) { var filterBuilder = new FilterDefinitionBuilder <User>(); var filter = filterBuilder.Empty; if (!String.IsNullOrWhiteSpace(login)) { filter = filter & filterBuilder.Eq("login", login); } if (id != null) { filter = filter & filterBuilder.Not(filterBuilder.Eq("id", id.Value)); } if (teamId != null) { filter = filter & filterBuilder.Eq("teamId", teamId.Value); } if (!String.IsNullOrWhiteSpace(teamName)) { filter = filter & filterBuilder.Eq("teamName", teamName); } var foundUsersList = await Users.Find(filter).ToListAsync(); return(foundUsersList.Count == 0); }
public PagedList <dynamic> GetSharedNodes(Guid userId, int pageNumber = 1, int pageSize = 20, bool isPublicOnly = false) { var filter = _filterBase & _builder.Eq("OwnedBy", userId) & _builder.Or( _builder.Eq("AccessPermissions.IsPublic", true), _builder.Not(_builder.Size("AccessPermissions.Users", 0)), _builder.Not(_builder.Size("AccessPermissions.Groups", 0)) ); if (isPublicOnly) { filter = filter & _builder.Eq("AccessPermissions.IsPublic", true); } var nodes = _nodes.Aggregate() .Lookup <BsonDocument, BsonDocument>(nameof(AccessPermissions), "_id", "_id", nameof(AccessPermissions)) .Unwind <dynamic>(nameof(AccessPermissions)) .Match(filter.Render(_nodes.DocumentSerializer, _nodes.Settings.SerializerRegistry)); return(PagedList(nodes, pageNumber, pageSize)); }
public static FilterDefinition <TDocument> NotDeactivated <TDocument>(FilterDefinitionBuilder <TDocument> builder, DateTime?dateTime = null) where TDocument : IActivationAware { if (!dateTime.HasValue) { dateTime = DateTime.UtcNow; } return(builder.Or( builder.Not( builder.Exists(doc => doc.DeactivationDate) ), builder.Gt(doc => doc.DeactivationDate, dateTime.Value) )); }
public static FilterDefinition <TDocument> NotDeactivated <TDocument, TItem>(FilterDefinitionBuilder <TDocument> builder, Expression <Func <TDocument, TItem> > acessor, DateTime?dateTime = null) where TItem : IActivationAware { if (!dateTime.HasValue) { dateTime = DateTime.UtcNow; } return(builder.Or ( builder.Not ( builder.Exists ( Expression.Lambda <Func <TDocument, object> > ( Expression.Convert ( Expression.Property ( acessor.Body, nameof(IActivationAware.DeactivationDate) ), typeof(object) ), acessor.Parameters ) ) ), builder.Gt ( Expression.Lambda <Func <TDocument, DateTime> > ( Expression.Convert ( Expression.Property ( acessor.Body, nameof(IActivationAware.DeactivationDate) ), typeof(DateTime) ), acessor.Parameters ), dateTime.Value ) )); }
public async System.Threading.Tasks.Task <bool> IsUnique(string name, long?id = null) { var filterBuilder = new FilterDefinitionBuilder <Team>(); var filter = filterBuilder.Empty; if (name != null) { filter = filter & filterBuilder.Eq("name", name); } if (id != null) { filter = filter & filterBuilder.Not(filterBuilder.Eq("id", id.Value)); } var foundTeamsList = await Teams.Find(filter).ToListAsync(); return(foundTeamsList.Count == 0); }
public static FilterDefinition <TEntity> NotDeleted <TEntity>(this FilterDefinitionBuilder <TEntity> filter) where TEntity : SoftDeletableMongoEntity => filter.Not(filter.Deleted());
public object Not(object filter) { return(InternalBuilder.Not(AsMongoFilter(filter))); }
public override FilterDefinition <T> Visit(NegateFilter <ClrValue> nodeIn, None args) { return(Filter.Not(nodeIn.Filter.Accept(this, args))); }
public override FilterDefinition <T> Visit(FilterNegate nodeIn) { return(Filter.Not(nodeIn.Operand.Accept(this))); }
public override FilterDefinition <TObject> BuildFilter(FilterDefinitionBuilder <TObject> filterBuilder) => filterBuilder.Not(Source.BuildFilter(filterBuilder));
//// //// 摘要: //// Tests that none of the subqueries is true (see $nor). //// //// 参数: //// queries: //// The subqueries. //// //// 返回结果: //// A query. //public static FilterDefinition<BsonDocument> Nor(params FilterDefinition<BsonDocument>[] queries) //{ // 未实现 //} // // 摘要: // Tests that the value of the named element does not match any of the tests that // follow (see $not). // // 参数: // name: // The name of the element to test. // // 返回结果: // The builder (so method calls can be chained). public static FilterDefinition <BsonDocument> Not(string name) { return(filter.Not(name)); }
private static void CreateOrderStatusFilter(HeatDataResultRequestDto input, FilterDefinitionBuilder <BsonDocument> builderFilter, List <FilterDefinition <BsonDocument> > filterDefinitions) { List <FilterDefinition <BsonDocument> > orderStatusFilterDefinitions = new List <FilterDefinition <BsonDocument> >(); input.OrderStatus.ForEach(x => { switch (x) { case InputOrderStatus.TotalStatus: default: break; case InputOrderStatus.CancelPlaceOrder: orderStatusFilterDefinitions.Add(builderFilter.And(builderFilter.In("orderStatus", new List <int>() { 30, 40, 45 }), builderFilter.Exists("updateTimeList.status5", false))); break; case InputOrderStatus.CancelAcceptOrder: orderStatusFilterDefinitions.Add(builderFilter.And(builderFilter.In("orderStatus", new List <int>() { 30, 40, 45 }), builderFilter.Exists("updateTimeList.status5", true))); break; case InputOrderStatus.CompletedOrder: orderStatusFilterDefinitions.Add(builderFilter.Exists("updateTimeList.status20", true)); break; case InputOrderStatus.ToBeCompletedOrder: orderStatusFilterDefinitions.Add(builderFilter.And(builderFilter.Exists("updateTimeList.status20", false), builderFilter.Not(builderFilter.In("orderStatus", new List <int>() { 30, 40, 45 })))); break; } }); if (orderStatusFilterDefinitions.Count > 0) { filterDefinitions.Add(builderFilter.Or(orderStatusFilterDefinitions)); } }