Adrian Cross
asked on
Return one column with a groupby query - List<int> anonymous type error
Hi, I want to store the values of one column (ColumnD) as a List<int> to use it as a look up later on.
The code above gives me the following error:
'cannot implicitly convert from anonymous Generic.List type <..> to Generic List<int>'
if i return the query as an object instead, it works. Then I can look for a value using this:
But how can I store the values of one column in a list??
Thanks!
List<int> query = (from t in db.TABLE where t.RecordID == recordID
group t by new { t.ColumnA, t.ColumnB,t.ColumnC }
into grp
select new { grp.ColumnD}).ToList();
return query;
The code above gives me the following error:
'cannot implicitly convert from anonymous Generic.List type <..> to Generic List<int>'
if i return the query as an object instead, it works. Then I can look for a value using this:
var x = data.Find(a => a.ColumnD == [a value]);
But how can I store the values of one column in a list??
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
No reply from the author but the proposed solution should work.
Open in new window