c# - Using substring within Linq expression -


i trying use substring within linq expression, cannot make work. here code:

categoriesbyid =             new dictionary<string, string>             {                 {"eventtype_1", "super classes"},                 {"eventtype_2", "master classes"},                 {"eventtype_3", "talks"},                 {"eventtype_4", "forums"}             };          ienumerable<customerdto> result =             _jsonserialiser.deserialise<importdto>(xml).imports;          var filteredresult = result             .where(s => s.categoryids                 .any(i => categoriesbyid.keys                     .contains(i))); 

the above works want match substring of s.categoryids. s.categoryids of type ienumerable. because of cannot use .substring or split on it. how can use .substring or split each s.categoryids within same linq?

thanks

you can call on categoriesbyid in any:

var filteredresult = result             .where(s => s.categoryids                 .any(i => categoriesbyid.keys.where(c => c.substring(3).contains(i))); 

Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

c# - Exception when attempting to modify Dictionary -