Trying to create a method that returns a query so I don't have to LINQ sort every time I need the results. LINQ code:
public IEnumerable<String> queryReturn()
{
string[] tr = staticGetTRdata();
char[] splitChars = new char[] { ',' };
var query = from data in tr
let columns = data.Split(splitChars, StringSplitOptions.None)
select new
{
qNames = columns[0].Substring(0, columns[0].Length - 6),
totCallW8 = Int32.Parse(columns[3]),
longW8InCall = columns[5],
longW8CallBack = columns[6],
BGtrLWC = columns[9].Substring(8),
BGtrLCB = columns[10].Substring(8),
}
into qSort
orderby qSort.qNames
select qSort;
return query;
}
From what I found on the web so far my issue lies with the "select new" statement which creates the AnonymousType, but I can't seem to figure out how to go around that. What else should I be selecting?
Also I'm just assuming I'm returning IEnumerable<String> or should I return something else? I want to be able to get the query in another method and do the foreach loop to sort the results from there. How would I be calling it?
What I have tried:
Found a couple similar issues on StackExchange, but can't figure out how to implement them. Writing select data doesn't seem to get me anywhere. Just get error after error.