我有一个存储库方法,例如,
public List<Township> lst(string multipletownship)
{
var foo = from x in db.Townships
select new { x.TownshipID, x.JTownshipName };
string[] sarr;
if (multipletownship.Contains(','))
{
sarr = multipletownship.Split(',');
foo = foo.Where(s => s.TownshipID == sarr[0] || s.TownshipID==sarr[1]);
}
else
{
foo = foo.Where(s => s.TownshipID == multipletownship);
}
multipletownship 参数值是1,2
。这些是乡镇 id。问题是我如何将 townshipid 过滤为多个。if condition
这可能或者我必须处理一些循环......