public class Notification
{
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string Id { get; set; }
[BsonElement("Text")]
public string Text { get; set; }
[BsonElement("Recipients")]
public List Recipients { get; set; }
[BsonElement("Read")]
public bool Read { get; set; }
}
public class RecipientsDocument
{
[BsonElement("Typer")]
public string Type { get; set; }
[BsonElement("Code")]
public string Code { get; set; }
[BsonElement("CodeId")]
public Guid? CodeId { get; set; }
}
public class NotificationQueryFilter
{
public string? CodeFilter { get; set; }
public TypeRecipientsEnum Type { get; set; }
public List CodeIds { get; set; }
}
В классе RecipientsDocument это свойство является новым -> public Guid? КодИд {получить; набор;
В этом методе я ищу документы на основе фильтров
У меня есть эта коллекция [code] public class Notification { [BsonId] [BsonRepresentation(BsonType.ObjectId)] public string Id { get; set; }
[BsonElement("Text")] public string Text { get; set; }
[BsonElement("Recipients")] public List Recipients { get; set; }
[BsonElement("Read")] public bool Read { get; set; } }
public class RecipientsDocument { [BsonElement("Typer")] public string Type { get; set; }
[BsonElement("Code")] public string Code { get; set; }
[BsonElement("CodeId")] public Guid? CodeId { get; set; } } [/code] И этот класс фильтра [code]public class NotificationQueryFilter { public string? CodeFilter { get; set; } public TypeRecipientsEnum Type { get; set; } public List CodeIds { get; set; } } [/code] В классе RecipientsDocument это свойство является новым -> public Guid? КодИд {получить; набор; В этом методе я ищу документы на основе фильтров [code]public async Task GetByCode(string code, int PageNumber, int PageSize, List codeIds = null) { var filter = BuildFilter(new NotificationQueryFilter() { CodeFilter = code, Type = TypeRecipientsEnum.Chief, CodeIds = codeIds?.ToList() });
int skip = (PageNumber - 1) * PageSize; var sortBuilder = Builders.Sort; var sort = sortBuilder.Descending(nameof(Notification.DataInserimento));
var docs = await GetCollection().Find(filter).Sort(sort).Skip(skip).Limit(PageSize).ToListAsync(); return docs; }