本文整理汇总了C#中System.Linq.ProjectTo方法的典型用法代码示例。如果您正苦于以下问题:C# System.Linq.ProjectTo方法的具体用法?C# System.Linq.ProjectTo怎么用?C# System.Linq.ProjectTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Linq
的用法示例。
在下文中一共展示了System.Linq.ProjectTo方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProjectingEnumToString
public void ProjectingEnumToString()
{
var customers = new[] { new Customer() { FirstName = "Bill", LastName = "White", CustomerType = CustomerType.Vip } }.AsQueryable();
var projected = customers.ProjectTo<CustomerDto>();
projected.ShouldNotBeNull();
Assert.Equal(customers.Single().CustomerType.ToString().ToUpper(), projected.Single().CustomerType);
}
示例2: Because_of
protected override void Because_of()
{
var sources = new[]
{
new Source
{
Value = 5
}
}.AsQueryable();
_dests = sources.ProjectTo<Dest>(Configuration).ToArray();
}
示例3: Because_of
protected override void Because_of()
{
IQueryable<Source> sources = new[]
{
new Source()
{
OtherValue = 10
}
}.AsQueryable();
_dest = sources.ProjectTo<Dest>().ToArray();
}
示例4: Because_of
protected override void Because_of()
{
var values = new[]
{
new Source()
{
Value = 5
}
}.AsQueryable();
_dest = values.ProjectTo<Dest>().ToArray();
}
示例5: Can_project_statically
public void Can_project_statically()
{
Mapper.Initialize(cfg =>
{
cfg.CreateMap<Source, Dest>();
});
var source = new Source {Value = 5};
var sources = new[] {source}.AsQueryable();
var dests = sources.ProjectTo<Dest>().ToArray();
dests.Length.ShouldEqual(1);
dests[0].Value.ShouldEqual(source.Value);
}