I have a csv file in the following format:

This rule sheet is loaded into an object List<DoctypeRule>
, I use this list to retrieve DocType values ββbased on RuleCode and RuleValue. The DoctypeRule class is as follows:
public class DoctypeRule
{
public string doctype {get; set; }
public string ruleCode {get; set; }
public string ruleValue {get; set; }
}
Now, to get the rule, I use LINQ and pass the parameter.
DoctypeRule rule = new DoctypeRule();
rule = lsdoctypeRules.Find(r => r.docType == myparameter);
I also want to get a doctype with similar rules and save it in a list. Since some of the RuleValue will have comma-separated values, I cannot get doctrines with similar rules Example:
string ruleCode = rule.ruleCode;;
string ruleValue = rule.ruleValue;
List<string> lsruleValues = ruleValue.Split(',').ToList();
Now, to compile doctypes with a similar rule, I used
var siblingDoctypes = lsdoctypeRules
.Where(r => r.ruleValue == ruleValue && r.ruleCode == ruleCode)
.Select(x => x.docType);
This is useful for getting doctypes when RuleValue has only one value. But when the values ββseparated by commas are, I tried something like this
var siblingDoctypes = lsdoctypeRules
.Where(r => r.ruleValue.Split(',').ToList().Any(lsruleValues.Any().ToString()) && r.ruleCode == ruleCode)
.Select(x => x.docType);
, lsruleValues
4
A, B- I, - II,
Doctypes
, , B- I, - II.