Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linq returning a IEnumerable<Dictionary<string,string>>

I need to return an IEnumerable of a dynamically created Dictionary.

pseudo code:

var x = from u in Users

select new dictionary<string, string>{
    Add("Name",u.Name),
    Add("LastName",u.LastName)
}

I've been trying many ways to get the pseudo code example above but no success...

I would really appreciate your help.

like image 879
Tony Avatar asked Aug 01 '10 05:08

Tony


1 Answers

var x = from u in Users
        select new Dictionary<string, string> {
            { "Name", u.Name },
            { "LastName", u.LastName }
        };
like image 129
mqp Avatar answered Nov 06 '22 05:11

mqp