我希望获得我意识到“Take() 不起作用的第一条记录。
所以我有一个查询另一个列表的列表
List<string> etchList = new List<string>();
etchList.Add("709");
Linq 查询是
var query = (from vio in AddPlas
where etchList.Any(vioID => vio.Key.Formatted.Equals(vioID))
select new
{
EtchVectors = vio.Shapes
}).ToList().Take(1);
现在这个“Take(1)”只有当我在 etchList 中有其他数据时才有效,所以它不是我想要的。我得到的结果如下所示:
格式化
的 "clinesegs" 1013.98 5142.96 "LYR3_SIG2"
"clinesegs" 1020.16 5168.33 "LYR3_SIG2"
"clinesegs" 967.03 5151.31 "LYR3_SIG2"
"clinesegs" 971.43 5174.01 "LYR3_SIG2"
我希望只取回列表中的第一行
"clinesegs" 1013.98 5142.96 "LYR3_SIG2"
编辑:
好的,此代码存在:
public class AddPla
{
public AddPla()
{
Shapes = new List<Parse>();
}
public Parse Key { get; set; }
public Parse Pla { get; set; }
public Parse Angle { get; set; }
public Parse Default { get; set; }
public List<Parse> Shapes { get; set; }
public Parse DoubleBrace { get; set; }
public Parse Number1 { get; set; }
public Parse Number2 { get; set; }
}
public class Parse
{
public string Formatted { get; set; }
public string Original { get; set; }
}
然后这个列表
var AddPlas = new List<AddPla>();