How to match a column which has multiple integer values separated by commas in linq?

I have list, in which i have column with multiple integer values(separated by commas).

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)
     )
 )
gett
ing 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))
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!