asp.net mvc - ServiceStack AutoQuery MVC controller -
i'm experimenting servicestack in mvc, using standard server side controllers creating view models. there no jquery calls (or direct calls) of services registered @ /api. since ss lets resolve services directly using:
using (var dr = hostcontext.resolveservice<datareportservice>(base.httpcontext))
i haven't been calling services using jsonserviceclient. instead i've been resolving services , calling methods directly.
var datareport = new datareport { isarchived = false, reportdate = datetime.now, reporttype = model.reporttype }; var drid = dr.post(datareport);
however, have not been able find way new autoquery feature. know creates service automatically class descends querybase have had no luck resolving it. if try resolve name used @ run time won't compile (obviously). if try this
using (var dr = hostcontext.resolveservice<autoqueryservicebase>(base.httpcontext))
then won't work either, because base class , not actual registered instance. know jsonserviceclient i'd experiment direct call approach. creating own service wraps autoquery work seems defeats purpose of automatic creation. still, don't see other way proceed. love hear ideas.
rather using resolveservice<t>
method service , call executing method yourself, can use hostcontext.servicecontroller.execute
method allows pass in request dto execute on action method.
var datareport = new datareport { isarchived = false, reportdate = datetime.now, reporttype = model.reporttype }; var drid = hostcontext.servicecontroller.execute(datareport);
i hope helps.
Comments
Post a Comment