gpt4 book ai didi

c# - LINQ 中的 Where IN 子句

转载 作者:IT王子 更新时间:2023-10-29 03:31:41 25 4
gpt4 key购买 nike

<分区>

如何制作类似于SQL Server中的where in子句?

我自己做了一个,但有人能改进一下吗?

    public List<State> Wherein(string listofcountrycodes)
{
string[] countrycode = null;
countrycode = listofcountrycodes.Split(',');
List<State> statelist = new List<State>();

for (int i = 0; i < countrycode.Length; i++)
{
_states.AddRange(
from states in _objdatasources.StateList()
where states.CountryCode == countrycode[i].ToString()
select new State
{
StateName = states.StateName

});
}
return _states;
}

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