本文整理汇总了C#中System.Linq.Expressions.AsQueryable方法的典型用法代码示例。如果您正苦于以下问题:C# System.Linq.Expressions.AsQueryable方法的具体用法?C# System.Linq.Expressions.AsQueryable怎么用?C# System.Linq.Expressions.AsQueryable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Linq.Expressions
的用法示例。
在下文中一共展示了System.Linq.Expressions.AsQueryable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SelectPropertyUsingIndex
public void SelectPropertyUsingIndex()
{
var source = new[]{
new { name="Prakash", custID=98088 },
new { name="Bob", custID=29099 },
new { name="Chris", custID=39033 }
};
string[] expected = { "Prakash", null, null };
Assert.Equal(expected, source.AsQueryable().Select((e, i) => i == 0 ? e.name : null));
}
示例2: NullableFloatFromSelector
public void NullableFloatFromSelector()
{
var source = new []
{
new { name = "Tim", num = (float?)5.5f },
new { name = "John", num = (float?)15.5f },
new { name = "Bob", num = default(float?) }
};
float? expected = 10.5f;
Assert.Equal(expected, source.AsQueryable().Average(e => e.num));
}
示例3: SelectProperty
public void SelectProperty()
{
var source = new []{
new { name="Prakash", custID=98088 },
new { name="Bob", custID=29099 },
new { name="Chris", custID=39033 },
new { name=(string)null, custID=30349 },
new { name="Prakash", custID=39030 }
};
string[] expected = { "Prakash", "Bob", "Chris", null, "Prakash" };
Assert.Equal(expected, source.AsQueryable().Select(e => e.name));
}
示例4: MinStringWitSelectorAccessingProperty
public void MinStringWitSelectorAccessingProperty()
{
var source = new[]{
new { name="Tim", num=100.45m },
new { name="John", num=10.5m },
new { name="Bob", num=0.05m }
};
Assert.Equal("Bob", source.AsQueryable().Min(e => e.name));
}
示例5: MinNullableDoubleWithSelectorAccessingProperty
public void MinNullableDoubleWithSelectorAccessingProperty()
{
var source = new[] {
new { name="Tim", num=(double?)-45.5 },
new { name="John", num=(double?)-132.5 },
new { name="Bob", num=default(double?) }
};
Assert.Equal(-132.5, source.AsQueryable().Min(e => e.num));
}
示例6: MinNullableDecimalWithSelectorAccessingProperty
public void MinNullableDecimalWithSelectorAccessingProperty()
{
var source = new[]{
new { name="Tim", num=(decimal?)100.45m },
new { name="John", num=(decimal?)10.5m },
new { name="Bob", num=default(decimal?) }
};
Assert.Equal(10.5m, source.AsQueryable().Min(e => e.num));
}
示例7: MaxInt64WithSelectorAccessingProperty
public void MaxInt64WithSelectorAccessingProperty()
{
var source = new[]{
new { name="Tim", num=10L },
new { name="John", num=-105L },
new { name="Bob", num=long.MaxValue }
};
Assert.Equal(long.MaxValue, source.AsQueryable().Max(e => e.num));
}
示例8: MinNullableInt64WithSelectorAccessingProperty
public void MinNullableInt64WithSelectorAccessingProperty()
{
var source = new[]{
new { name="Tim", num=default(long?) },
new { name="John", num=(long?)long.MinValue },
new { name="Bob", num=(long?)-10L }
};
Assert.Equal(long.MinValue, source.AsQueryable().Min(e => e.num));
}
示例9: NullableLongFromSelector
public void NullableLongFromSelector()
{
var source = new []
{
new { name = "Tim", num = (long?)40L },
new { name = "John", num = default(long?) },
new { name = "Bob", num = (long?)30L }
};
double? expected = 35;
Assert.Equal(expected, source.AsQueryable().Average(e => e.num));
}
示例10: NullableDecimalFromSelector
public void NullableDecimalFromSelector()
{
var source = new[]
{
new{ name = "Tim", num = (decimal?)5.5m},
new{ name = "John", num = (decimal?)15.5m},
new{ name = "Bob", num = (decimal?)null}
};
decimal? expected = 10.5m;
Assert.Equal(expected, source.AsQueryable().Average(e => e.num));
}
示例11: MaxNullableDoubleWithSelectorAccessingProperty
public void MaxNullableDoubleWithSelectorAccessingProperty()
{
var source = new []{
new { name = "Tim", num = (double?)40.5},
new { name = "John", num = default(double?)},
new { name = "Bob", num = (double?)100.45}
};
Assert.Equal(100.45, source.AsQueryable().Max(e => e.num));
}
示例12: MaxStringWithSelectorAccessingProperty
public void MaxStringWithSelectorAccessingProperty()
{
var source = new[]{
new { name="Tim", num=420.5m },
new { name="John", num=900.25m },
new { name="Bob", num=10.45m }
};
Assert.Equal("Tim", source.AsQueryable().Max(e => e.name));
}
示例13: MaxNullableInt64WithSelectorAccessingField
public void MaxNullableInt64WithSelectorAccessingField()
{
var source = new[]{
new {name="Tim", num=default(long?) },
new {name="John", num=(long?)-105L },
new {name="Bob", num=(long?)long.MaxValue }
};
Assert.Equal(long.MaxValue, source.AsQueryable().Max(e => e.num));
}
示例14: MaxNullableSingleWithSelectorAccessingProperty
public void MaxNullableSingleWithSelectorAccessingProperty()
{
var source = new[]
{
new { name="Tim", num=(float?)40.5f },
new { name="John", num=(float?)null },
new { name="Bob", num=(float?)100.45f }
};
Assert.Equal(100.45f, source.AsQueryable().Max(e => e.num));
}
示例15: MaxNullableInt32WithSelectorAccessingField
public void MaxNullableInt32WithSelectorAccessingField()
{
var source = new[]{
new { name="Tim", num=(int?)10 },
new { name="John", num=(int?)-105 },
new { name="Bob", num=(int?)null }
};
Assert.Equal(10, source.AsQueryable().Max(e => e.num));
}