My class defines Id as the key. I’ve created a GetAll() function using the following:
var query = from q in _context.Query()
_context is a BucketContext
The docs returned contain all the data but the id is always null. Can someone please explain to me why?
I assume you’re referring to Linq2Couchbase here? I believe you’ll need to use
N1QlFunctions.Meta. In Couchbase, the Id is not part of the document, but rather meta data about the document.
For more information, see the Linq2Couchbase docs on Meta
You may also use
N1qlFunctions.Key(q) in the select projection as a shortcut directly to the key.
Thanks Matthew and btburnett!