c# - Create LINQ statement with variable column names -
this question has answer here:
- linq : dynamic select 5 answers
i creating tree view flat table. have linq query returns distinct values column
public actionresult index() { var result = (from in db.items select i.geoname) .distinct() .orderby(n => n); return view(result); }
this of course returns view beginning nodes (lets hypothetically 'node1', 'node2', , 'node3').
i have user click on node, , return contents of column well.
how do dynamically?
i hoping simple (and may be, don't know - linq newb!) as:
public actionresult index() { var result = (from in db.items select i.passedincolumnname) .distinct() .orderby(n => n); return view(result); }
as always, in advance helpful folks.
you can using expression trees pretty in depth, suggest using sql linq isn't best solution want do.
the sql be:
select distinct passedincolumnname items geoname = 'the geo name' order passedincolumnname
Comments
Post a Comment