Link to home
Start Free TrialLog in
Avatar of PeterTrefren
PeterTrefrenFlag for United States of America

asked on

linq query with ordered columns

I'm new to Linq and I'd like to rewrite the query I use to return results from a DomainService so that the columns are returned and a specific order.  If this was SQL I would use somthing like SELECT col1, col2, col3 from myTable.  The rows will be loaded into a datagrid in a Silverlight app.
public IQueryable<myTable> GetMyTable()
        {
            return this.ObjectContext.myTable.OrderBy(e => e.ItemID);
            
        }

Open in new window

Avatar of kaufmed
kaufmed
Flag of United States of America image

I'm not 100% on this, but have you tried switching the order of the properties as defined in your myTable class?
Im not sure how you would do it with a datatable but, the syntax looks like this if you have a specific object your using:

var test = from t in myListFromDomainObject
                 select new BindingObjectThatICreated
                 {
                      ObjectVal = t.ObjectVal,
                      ObjectVal2 = t.ObjectVal2
                 }

Here are some pretty good basic examples:  http://msdn.microsoft.com/en-us/vcsharp/aa336756

Hope this helps, if you need more direction just let me know.

ASKER CERTIFIED SOLUTION
Avatar of PeterTrefren
PeterTrefren
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of PeterTrefren

ASKER

This provides the what I wanted.