Why any Time Zone is automatically converting to Local Time Zone when retrieving from Couchbase SDK using .Net SDK 3.2.8

In couchbase : “eventTime”: “2022-04-14T19:40:00-07:00”,
From .net 3.2 SDK : “eventTime”:“2022-04-14T18:40:00-04:00”

Please check attached images. For same data in couchbase , getting differebt results from .net SDK2.7 and SDK3.2.8
Right side is with SDK 3.2 and left side with SDK 2.7


IBucketContext bucketContext = new BucketContext(await _getBucket());

        return bucketContext.Query<Order>()
                            .ScanConsistency(ScanConsistency.RequestPlus);




        Above code data returned in orderRequest and then filtered using following code         orderEventData = orderRequest?.Where(oe => oe.PE == partner.Id
                && oe.References != null && oe.References.Any(x => x == shipmentReference))
                    ?.OrderByDescending(e => e.DateCreated)
                    ?.ToList();

Only if we try collection.GetAsync(documentId) its returning correct data. Even tried using N1QL quey but got same result as wrong datetime

1 Like

Hi,

Just want to let you know a support ticket has been opened on this issue and the SDK team is investigating this.

Thanks,
Aaron

1 Like

@rajkumarmore

There are couple of things that may help with the diagnosis, if you have them (assuming you haven’t already given them to the SDK team):

  • Can you show how you’re configuring your ClusterOptions?
  • Can you confirm the version of Linq2Couchbase you are using?
  • Can you provide the definition of the POCOs for Order and it’s children?
3 Likes
  1. Configuration in Startup.cs
    Used this configuration
    services.AddCouchbase(options =>
    {
    Configuration.GetSection(“Couchbase”).Bind(options);
    options.AddLinq();
    });
    services.AddCouchbaseBucket(Configuration.GetValue(“CouchbaseStorageBucketName”));
  2. Linq2Couchbase version
    Linq2Couchbase Version=“2.0.0”
  3. POCO
    POCO.zip (836 Bytes)
    EventTime – This field is getting wrong data through SDK
1 Like

@rajkumarmore

I believe we have narrowed down this problem to a quirk in the Newtonsoft.Json deserializer that only affects the streaming deserializer we use for queries. We are working on a fix.

There seems to be a workaround available in the meantime. You can configure a custom instance of DefaultSerializer with custom options, and set DateParseHandling to DateTimeOffset. Alternatively, though somewhat more involved, you could switch to System.Text.Json serialization.

Here is the issue you can follow: https://issues.couchbase.com/browse/NCBC-3195

1 Like

Thanks @btburnett3 , as per ticket its scheduled for 3.3.2. Current nuget version is 3.2.9 , by when can expect 3.3.2 available?
I tried with custom instance of DefaultSerializer with custom options but did not worked so will wait for SDK next version.

@rajkumarmore

3.3.2 will be the next release, I’m assuming in the next few weeks but someone on the SDK team should be able to speak better to the current release cycle.

Can you give me the code you tried for a custom deserializer?

1 Like

@rajkumarmore

3.3.1 will be released today; 3.3.2 is scheduled for the first Tuesday in June. Generally, we always release the first Tuesday of every month.

Jeff

1 Like