I'm using a query to get records from a table named customers and I want to order the records by address, housenumber, surname, name
.
First I used this (DataTable)
public CustomerInfo.customers GetCustomers(string zipcode) {
string sql = "select id, name, surname, zipcode, housenumber where zipcode = @_zipcode order by address, housenumber, surname, name";
....
}
now I use this:
public OrderedEnumerableRowCollection<CustomerInfo.customerRow> GetCustomers(string zipcode) {
string sql = "select id, name, surname, zipcode, housenumber where zipcode = @_zipcode";
....
return (from c in datatable).OrderBy(c => c.Address).ThenBy(....).ThenBy(...);
}
Is that the right way to improve performance ...?
What are the (dis)advantages of the OrderedEnumerableRowCollection
vs DataTable
?
Please let me know how you should do this.