Im trying to figure out a way to handle server side filtering where our controllers return viewmodels rather than the actual entity. Because a viewmodel is being bound to the grid, when ever I sort or filter the field that is being sent back to the controller is the property name from the viewmodel and does not match to the entity. Because of this I can't do a dynamic where clause as the where clause contains the field of the viewmodel (CarName) and not the entity (Name). Somehow I need a way to map the filter for the viewmodel fields back to the entity so that I can filter properly.
Here are the basic steps:
Call Repository Get IQueryable<Car> Entity
Filter and sort Data (With Dynamic Query)
Convert entity to viewmodel with Automapper
Return viewmodel
Just to point out im using the Kendo UI Web and not the MVC wrappers.
Here are the basic steps:
Call Repository Get IQueryable<Car> Entity
Filter and sort Data (With Dynamic Query)
Convert entity to viewmodel with Automapper
Return viewmodel
-- This represents my entity and view model, both the fields are the same but have slightly different names
public
class
Car {
public
string
Name {
get
;
set
; }
}
public
class
CarViewModel {
public
string
CarName {
get
;
set
; }
}