So lets say we have a class called "Report" that has a name and a list of column names in CSV form.
public class Report
{
public string ReportName { get; set; }
public string ColumnNames { get; set; }
}
Then we have a class called "Context" that holds a list of reports.
public class ContextClass
{
public List<Report> Reports { get; set; }
}
Then we initialize the Context class with a new report called "Report1" that has 3 columns and add it to the list
var Context = new ContextClass();
Context.Reports = new List<Report>();
Context.Reports.Add(new Report()
{
ReportName = "Report1",
ColumnNames = "Col1,Col2,Col3"
});
Then in the context of your method, a "ReportName" is passed in called "Report1"
var ReportName = "Report1";
We can then return the values as a list of string as per your original posted code"
var ColumnNames = Context.Reports.Where(c => c.ReportName == ReportName).Select(c => c.ColumnNames.Split(',')).ToList();
return ColumnNames
I've tested this locally and it works fine.
Thanks