Subsonic - Return only certain columns/properties for display

I have a baseclass that handles returning data from the relevant class/table.

I want to have some way of specifying the columns to display. Maybe have a public columns List that gets assigned with all column we want to display?

This is what I have but its not right.

public void SetupGrid<T>() where T : class, new()
        {
            var db = new MyApp.MyDB();
            IRepository<T> repo = new SubSonicRepository<T>(db);
            var s = repo.GetAll();


            var x = from c in s select new { c.Columns //that match columns I specify };

        }

Answers


This seems to do it, however unsure if its best practice:

 public virtual void SetupGrid<T>() where T : class, new()
        {
            MyApp.MyDBdb = new MyApp.MyDB();
            IRepository<T> repo = new SubSonicRepository<T>(db);
            ITable table = repo.GetTable();


            List<string> list = new List<string>();
            list.Add("CreatedOn");
            list.Add("PageID");
            list.Add("CreatedBy");

            var s = db.SelectColumns(list.ToArray()).
                    From(table.Name).
                    OrderAsc(table.Descriptor.Name).ExecuteReader();



            bindingSource1.DataSource = s;



        }

Need Your Help

Universal descriptions for emails across different clients

html email meta-tags mailchimp

Is there a universal way to set the lead-in, description, meta text for an email in email campaigns?

on mouse enter slide from left to right background position with jQuery

javascript jquery jquery-ui css3 background-position

I have a button for which I want to slide his background from #000 to #ccc.