本文整理汇总了C#中ISpecification.SatisfiedBy方法的典型用法代码示例。如果您正苦于以下问题:C# ISpecification.SatisfiedBy方法的具体用法?C# ISpecification.SatisfiedBy怎么用?C# ISpecification.SatisfiedBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISpecification
的用法示例。
在下文中一共展示了ISpecification.SatisfiedBy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AllMatching
public IEnumerable<User> AllMatching(ISpecification<User> specification)
{
lock (_users)
{
return _users.Where(specification.SatisfiedBy());
}
}
示例2: GetSummary
public Summary GetSummary(ISpecification<Expence> spec)
{
double total =
_expencesSet
.Where(spec.SatisfiedBy())
.Sum(e => e.Total);
return new Summary(total);
}
示例3: GetCategoriesRating
public IEnumerable<CategorySummary> GetCategoriesRating(ISpecification<Expence> spec)
{
return
_expencesSet
.Where(spec.SatisfiedBy())
.GroupBy(e => e.Category)
.Select(g =>
new CategorySummary
{
CategoryName = g.Key.Name,
Total = g.Sum(e => e.Total),
ExpencesCount = g.Count()
})
.OrderByDescending(cs => cs.Total)
.ToList();
}
示例4: GetAdvertisementsList
public IEnumerable<Ad> GetAdvertisementsList(ISpecification<Advertisement> specification)
{
List<Ad> ads = (from advertisement in dbContext.Advertisements.Where(specification.SatisfiedBy())
select new Ad
{
Id = advertisement.AdvertisementID,
ProductId = advertisement.ProductID,
CategoryId = advertisement.Product.ProductGroupID.Value,
Title = advertisement.Title,
StartDate = advertisement.StartDate,
EndDate = advertisement.EndDate,
IsActive = advertisement.IsActive.Value,
UserId = advertisement.OwnerID
}).ToList<Ad>();
return ads;
}