You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
786 B
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using Xunit;
namespace LinqStudy.Test.LinqToObject
{
/// <summary>
/// 选件筛选
/// </summary>
public class WhereTest
{
/// <summary>
/// Where条件筛选操作,延迟执行
/// </summary>
[Fact]
public void Where_Test()
{
List<Person> peoples = new List<Person>()
{
new Person(){ Id=1, Name="wanggaofeng", Age=33},
new Person(){ Id=2, Name="lishi", Age=32},
};
var query = peoples.Where(q => q.Name.StartsWith("wang"));
var selectId = query.FirstOrDefault().Id;
Assert.Equal(1, selectId);
}
}
}