c# - How to use automapper in orderby clause with dynamic linq? -
i'm using orderproperties variable dynamic linq , need use automapper in orderby clause. need map "mycolumn" property resource class other property resourceviewmodel class. query() returns iquerable of resource. example have in resouce class mycolumn property , need map myothercolumn, in resourceviewmodel. ideas how that?
string orderproperties = "mycolumn ascending"; var orderlist = _resourcerepository.query() .orderby(orderproperties) .select(mapper.map<resource, resourceviewmodel>);
i try approach:
- store result of query in variable
- and translate resultset using automapper.
the ordering should work independent automapper. autommapper "translates" stuff.
something this:
string orderproperties = "mycolumn ascending"; var orderlist = _resourcerepository.query() .orderby(orderproperties) .tolist(); mapper.createmap<ilist<resource>, ilist<resourceviewmodel>>(); var results = mapper.map<ilist<resource>>(orderlist);
hth
Comments
Post a Comment