PeterTrefren
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);
}
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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This provides the what I wanted.