gpt4 book ai didi

c# - Ienumerable concat 不适用于每个循环

转载 作者:行者123 更新时间:2023-11-30 14:07:36 25 4
gpt4 key购买 nike

<分区>

我试图在 for each 循环中使用 IEnumerable 的 Concat 方法,但我无法使其正常工作。

IEnumerable<Geo> geos = null;
foreach (string a in values)
{
if (geos == null)
geos = entities.Geos.Where(g => (g.ACode == Convert.ToInt16(a)));
else
geos = geos.Concat(entities.Geos.Where(g => (g.ACode == Convert.ToInt16(a))));
}

它返回的只是值中最后一个“a”的值,以及值中存在的记录数。

所以如果我有 1,2,3 作为值,它只返回 3。我也需要 1,2 和 3 的值。

我哪里错了?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com