This is a migrated thread and some comments may be shown as answers.
Server Side Filtering With Automapper and ViewModels
1 Answer 44 Views
This is a migrated thread and some comments may be shown as answers.
lmf232s
Top achievements
Rank 1
lmf232s asked on 22 Nov 2013, 02:41 PM
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
-- 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; }
}
Just to point out im using the Kendo UI Web and not the MVC wrappers.

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 26 Nov 2013, 02:19 PM
Hello Larry,

I am afraid the question is not related to the web Kendo framework but to .NET and its MVC framework. I would suggest you to search for help on forums such as stackoverflow and the official aspnetmvc forums.

http://stackoverflow.com/
http://forums.asp.net/1146.aspx


Kind Regards,
Petur Subev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
lmf232s
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or