Here's the LINQ query I have, it gets the unique value for each selected column and stores them as a list in a dictionary.
var serialTable = serialNoAdapter.GetData();
var distinctValue = (from row in serialTable
select new
{
row.CodePractice,
row.LockType,
row.Software
}).Distinct().ToList();
var softwareValue = distinctValue.Select(p => p.Software).Distinct().ToList();
var codeValue = distinctValue.Select(p => p.CodePractice).Distinct().ToList();
var lockValue = distinctValue.Select(p => p.LockType).Distinct().ToList();
return new Dictionary<string, List<string>>()
{
{"software", softwareValue},
{"codepractice", codeValue},
{"locktype", lockValue}
};
The only problem is it is broken up into a few statements. My question is is it possible to simplify it and compact it into a single statement?