本文整理汇总了C#中Source.Count方法的典型用法代码示例。如果您正苦于以下问题:C# Source.Count方法的具体用法?C# Source.Count怎么用?C# Source.Count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Source
的用法示例。
在下文中一共展示了Source.Count方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Select_destinations_items_with_query_by_source_items
public void Select_destinations_items_with_query_by_source_items()
{
Mapper.Initialize(cfg =>
{
cfg.CreateMap<Source, Destination>()
.ForMember(d => d.DestValue, opt => opt.MapFrom(s => s.SrcValue));
});
IQueryable<Destination> detsResult = new Source[0]
.AsQueryable()
.Where(s => s.SrcValue > 6)
.Map<Source, Destination>(_destinations.AsQueryable());
detsResult.Count().ShouldEqual(1);
detsResult.First().GetType().ShouldEqual(typeof(Destination));
}
示例2: Select_source_items_from_destinations
public void Select_source_items_from_destinations()
{
var config = new MapperConfiguration(cfg =>
{
cfg.CreateMap<Source, Destination>()
.ForMember(d => d.DestValue, opt => opt.MapFrom(s => s.SrcValue))
.ReverseMap(); // reverse map added
});
IQueryable<Source> sourceResult = new Source[0]
.AsQueryable()
.Where(s => s.SrcValue > 6)
.Map<Source, Destination>(_destinations.AsQueryable(), config)
.ProjectTo<Source>(config); // projection added
sourceResult.Count().ShouldEqual(1);
sourceResult.First().GetType().ShouldEqual(typeof(Source));
}
示例3: Count_CountsItems
public void Count_CountsItems()
{
var queryable = new[] { "1", "3", "6", "2", "8" }.AsQueryable();
var source = new Source<string>(queryable);
Assert.AreEqual(queryable.Count(), source.Count());
}