我有这段代码
var events = Filter(context.Events.AsNoTracking())
.Select(e => new EventDto
{
Id = e.Id,
SupplierId = e.SupplierId,
Supplier = e.Supplier.FullName,
DocumentType = e.DocumentType.Title,
ScheduledDate = e.ScheduledDate
})
.ToList();
var suppliers = events.Select(e => e.SupplierId).ToList();
var eventsBySupplier = events.GroupBy(e => e.SupplierId).ToDictionary(g => g.Key, g => g.ToList());
LogEvents(eventsBySupplier);
var subscriptions = context.Subscriptions.AsNoTracking()
.Include(e => e.User)
.Include(e => e.Supplier)
.Include(e => e.Supplier.Responsible)
.Where(e => suppliers.Contains(e.SupplierId))
.Where(e => notifiedRoles.Contains(e.User.Role))
.ToList();
LogSubscriptions(subscriptions);
我需要在这里添加检查供应商是否有效。
供应商有财产
public bool Active { get; set; }
所以我需要添加检查e.Active == active
,但我不知道该怎么做。
有人可以告诉我该怎么做吗?
答案 0 :(得分:2)
更改此行
.Where(e => suppliers.Contains(e.SupplierId))
到
.Where(e => suppliers.Contains(e.SupplierId) && e.Active == active)