QueryAsync<T> does not assign values to the created object

When I am execusting a query with QueryAsync, it does not assign values to the prperties. It creates object with default values only.

See the below image. The properties which has values are default values.

[Note]: Using CouchbaseNetClient 3.4.4

The most common cause of this problem is not having your select projection align correctly with the POCO you’re deserializing to.

As an example

SELECT * FROM bucket WHERE type = 'tally' LIMIT 1

Will not project cleanly onto a Tally object. This is because the * projection nests the resulting object underneath the bucket name. This is by design to help with more advanced join scenarios.

You can change your query to this to remove the nesting, which should then deserialize correctly:

SELECT bucket.* FROM bucket WHERE type = 'tally' LIMIT 1

You can also try using the Linq2Couchbase NuGet package, which handles a lot of these scenarios for you transparently.

If this isn’t your problem, please reply with the example query and your POCO class.

1 Like

Thank you so much. That works.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.