選擇一個物業的第一記錄我有一個類使用LINQ
class Test
{
public string FirstProp { get; set; }
public string SecondProp { get; set; }
public string ThirdProp { get; set; }
}
和對象
var list = new List<Test>
{
new Test { FirstProp = "xxx", SecondProp = "x2", ThirdProp = "x3" },
new Test { FirstProp = "xxx", SecondProp = "x21", ThirdProp = "x31" },
new Test { FirstProp = "yyy", SecondProp = "y2", ThirdProp = "y3" },
new Test { FirstProp = "yyy", SecondProp = "y21", ThirdProp = "y31" },
new Test { FirstProp = "xxx", SecondProp = "x22", ThirdProp = "x32" },
};
我需要選擇第一FirstProp記錄列表:
FirstProp = "xxx", SecondProp = "x2", ThirdProp = "x3"
FirstProp = "yyy", SecondProp = "y2", ThirdProp = "y3"
如何以最好的方式使用linq
?
你的問題不清楚。 – MarcinJuraszek 2013-03-20 10:43:32
你說你想選擇「FirstProp」,你選擇「FirstProp =」xxx「,SecondProp =」x2「,ThirdProp =」x3「」? – Popeye 2013-03-20 10:44:18
我只需要FirstProp ==「xxx」的第一條記錄,首先是「yyy」,首先是「someother」等。 – Shymep 2013-03-20 10:45:19