Come creare una clausola where in una simile in SQL Server?Dove clausola IN in LINQ
Ne ho fatto uno da solo ma qualcuno può migliorare questo?
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;
}
questo confronta i valori stringa, ma per quanto riguarda gli ID ?? –
@JitendraPancholi È possibile utilizzare un join per i numeri interi. – Eugene
@JitendraPancholi se si crea un elenco è possibile verificare gli ID. È supportato in .Net 4. Non sono sicuro delle versioni precedenti. –