Thursday, 15 September 2011

ServiceStack AutoQuery not working for DateTime values -


I have a service stack service using the autoquarium where the date or even less is being neglected.

Here my request is DTO:

  Public class GetSources: QueryBase & lt; DbSource, Source & gt; {Public string name {get; Set; } Public String NameContains {get; Set; } Public string NameStartsWith {get; Set; } Public Date Time? Get the last update; Set; } Public Date Time? Get the last updated date {Get; Set; }}  

The database table generated from the ormlite T4 template looks like this:

  [alias ("DbSources")] [schema ("Some hacka ")] Public partial class DbSource {[AutoIncrement} public int id {get; Set;} [required] public string name {get; Set;} [Required] Public Date Time Last Update Date {Received; In the service;}}  

I make some verification in the service and then use AutoQuery like this:

  var q = AutoQuery.CreateQuery (dto , Request GetRequestParams ()); Q. Jan & lt; DBSOS, Company Source & gt; ((Source, Company Source) => Source.id == Company Source. Source ID and Company Source.CompanyID == Company ID); Return AutoQuery.Execute (dto, q);  

I am using mstest

  [TestMethod] Public Zero GetSources_LastUpdatedGreaterThan () {var = dateTime.Now; Var query = new GetSources {LastUpdatedDateGreaterThan = expected}; QueryResponse & LT; Source & gt; result; {Service.Request = new MockHttpRequest (); (Var service = appHost.Container.Resolve & lt; SourceService & gt; ()); Results = Service. Any (query); } Log.Info (result.Toson ()); result. result. ForEach (src = & gt; dependent. ISRU (src.LastUpdatedDate & gt; required); }  

The name, the name company, and the name Starstus do all the work required in other tests, but the last updated data-generator and the last updated lotaton do not generate a single volume. All the attributes in my AutoQuery setup are default by excluding EnableUntypedQueries by default.

I know where I can add to them in the service clearly I.e.

  q.Where (source = & gt; source.LastUpdatedDate & gt; dto.LastUpdatedDateGreaterThan);  

But if possible, should I need AutoQuery to work with DateTime AutoQuery? Or am I doing something wrong in my code.

I took part in the Service Stake Autocommy Unit tests which I used to make using MS SQL Tested using a database view that was interrogating my original project and I was not able to repeat the issue that I am running. For now I will add the QueryField attribute to the query model on such datetime properties:

  [queryfile (template = "{field}> gt; {value}", field = "last update Date ")] Public Date Time? Get the last update; Set; }  

Adding the attribute gives me what I need. I will spend some time tracking down the culprit in my code later.


No comments:

Post a Comment