c# - how to use parameter in linq to select different columns -


i want use linq select columns populate each combobox. right have individual linq query job. wish write method that.

var getusername = entity.select(a=>a.username); var gettype  = entity.select(a=>a.type); var getaddress  = entity.select(a=>a.address); 

can that:

   public object getdata(string columnname) {    var q = in entity               select columnname;  return q.distinct();      }  combobox1.bindingsource = getdata("username"); combobox2.bindingsource = getdata("type"); combobox3.bindingsource = getdata("address"); 

do need write construct?

dynamic linq helpful in situation.
here tutorial.
code need this:

    public object getdata (string colname) {       northwinddatacontext db = new northwinddatacontext();       var q = db.products.select(colname);       list list = new list();       foreach (var element in q) {         if (!list.contains(element))           list.add(element);       }       return list;

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -