views:

26

answers:

1

i have function

 public List<string > UserList()
    {
        var q = from i in _dataContext.PageStat group i by new { i.UserName } into ii select new { ii.Key.UserName };


    }

how can i return List ?

+1  A: 

It looks like you just want the distinct set of usernames... why not just use:

return _dataContext.PageStat.Select(u => u.UserName)
                            .Distinct()
                            .ToList();

If you really want to use grouping, you could do:

var q = from i in _dataContext.PageStat
        group i by i.UserName into ii
        select ii.Key;
return q.ToList();

You don't need all those anonymous types :)

Jon Skeet