public Class SomeModel
{
public int Id { get; set;}
public string Name {get; set;}
}
this is the method I'm binding values to above model, it contains inline SQL Queries
Public ActionResult GetData()
{
IEnumarable<SomeModel> alltheListValues = ....
}
using above method, I want to filter all the record that containing ids in following string.
string filterIds = "12,13,14,15"
SomeModel model class Id
values are in Integer type, but I have string type id set, without going for looping this, I decided to use WHERE IN query to filter this.
since WHERE IN query we can get in Linq as contains
I wrote down follwoing function to filter values
IEnumarable<SomeModel> filterValues = GetData.Where(Id=> Id.ToString().Contains(filterIds));
but this is not selecting any value always zero filter result, how can I wrote this properly
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…