private static FilterDefinition <MongoContentEntity> CreateFilter(DomainId appId, IEnumerable <DomainId> schemaIds, ClrQuery?query, DomainId referenced, RefToken?createdBy) { var filters = new List <FilterDefinition <MongoContentEntity> > { Filter.Eq(x => x.IndexedAppId, appId), Filter.In(x => x.IndexedSchemaId, schemaIds), }; if (query?.HasFilterField("dl") != true) { filters.Add(Filter.Ne(x => x.IsDeleted, true)); } if (query?.Filter != null) { filters.Add(query.Filter.BuildFilter <MongoContentEntity>()); } if (referenced != default) { filters.Add(Filter.AnyEq(x => x.ReferencedIds, referenced)); } if (createdBy != null) { filters.Add(Filter.Eq(x => x.CreatedBy, createdBy)); } return(Filter.And(filters)); }
public static FilterDefinition <MongoAssetEntity> BuildFilter(this ClrQuery query, DomainId appId, DomainId?parentId) { var filters = new List <FilterDefinition <MongoAssetEntity> > { Filter.Exists(x => x.LastModified), Filter.Exists(x => x.Id), Filter.Eq(x => x.IndexedAppId, appId) }; if (!query.HasFilterField("IsDeleted")) { filters.Add(Filter.Eq(x => x.IsDeleted, false)); } if (parentId != null) { if (parentId == DomainId.Empty) { filters.Add( Filter.Or( Filter.Exists(x => x.ParentId, false), Filter.Eq(x => x.ParentId, DomainId.Empty))); } else { filters.Add(Filter.Eq(x => x.ParentId, parentId.Value)); } } var(filter, last) = query.BuildFilter <MongoAssetEntity>(false); if (filter != null) { if (last) { filters.Add(filter); } else { filters.Insert(0, filter); } } return(Filter.And(filters)); }