0

我有这个代码

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; }

所以我需要添加检查 if e.Active == active,但我不知道该怎么做。

有人可以告诉我怎么做吗?

4

1 回答 1

2

更改此行

.Where(e => suppliers.Contains(e.SupplierId))

.Where(e => suppliers.Contains(e.SupplierId) && e.Active == active)
于 2013-07-10T12:37:29.300 回答