我希望只获取第一条记录,但是我发现 "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>();