How to match a column which has multiple integer values separated by commas in linq?
Options
I have list, in which i have column with multiple integer values(separated by commas).
eg:
cannot convert string to int
Can any one plz help me.
Thanks
eg:
------------------------ | Program | Module | ------------------------ | I | 1,2,3 | ------------------------ | II | 2, 3 | ------------------------ | III | 1,3 | ------------------------Now, supppose, if i want to select programs where module is 2.
int sid = 2; IEnumerable<int> ids = Program.All.FindAll( item => sid.contains( item.Module.Split(',').Select(s => (int)s) ) ) getting compilation error:
cannot convert string to int
Can any one plz help me.
Thanks
Comments
-
tried so far:
IEnumerable<int> moduleIds = filterType == ListingFilterType.Equals ? ModuleController.Instance.All.FindAll(item => item.Code != null && item.Code.ToUpper() == value.ToUpper()).Select(item => item.ID) : ModuleController.Instance.All.FindAll(item => item.Code != null && item.Code.ToUpper().Contains(value.ToUpper())).Select(item => item.ID); return All.FindAll(item => item.MandatoryModuleDetails.Split(',').Any(s => s.Trim() == moduleIds.ToString()));
-
try
.Select(s => int.Parse(s))