Hi Telerik,
it is possible sort data in grid on server side with viewmodel which has navigation property to customer. Or I have to create new SQL view which will group data from two tables(Order and Customer together). I will be able to sort data from mssql view.
// Models
public class Order
{
public int OrderID { get; set; }
public Customer Customer { get; set; }
}
public class Customer
{
public string ContactName { get; set; }
}
// Action
public ActionResult Read([DataSourceRequest] DataSourceRequest request)
{
var dataContext= new DataContext();
var orders = dataContext.Orders;
var result = orders.ToDataSourceResult(request, o => new {OrderID = o.OrderID, CustomerName = o.Customer.ContactName});
return result;
}
Now i want sort data according to CustomerName then error occures.
MSSQL view solve this problem?
it is possible sort data in grid on server side with viewmodel which has navigation property to customer. Or I have to create new SQL view which will group data from two tables(Order and Customer together). I will be able to sort data from mssql view.
// Models
public class Order
{
public int OrderID { get; set; }
public Customer Customer { get; set; }
}
public class Customer
{
public string ContactName { get; set; }
}
// Action
public ActionResult Read([DataSourceRequest] DataSourceRequest request)
{
var dataContext= new DataContext();
var orders = dataContext.Orders;
var result = orders.ToDataSourceResult(request, o => new {OrderID = o.OrderID, CustomerName = o.Customer.ContactName});
return result;
}
Now i want sort data according to CustomerName then error occures.
MSSQL view solve this problem?