相关疑难解决方法(0)

LINQ中的IN子句

如何在SQL Server中创建一个类似于where的子句?

我自己做了一个,但任何人都可以改进吗?

    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;
    }
Run Code Online (Sandbox Code Playgroud)

c# linq

147
推荐指数
5
解决办法
44万
查看次数

标签 统计

c# ×1

linq ×1