couchbase/docs-sdk-dotnet

.NET SDK SubDocuments?

Closed this issue ยท 6 comments

I am new to Couchbase, so please forgive my ignorance here. Looking through this documentation as well as the documentation on the docs.couchbase.com site (https://docs.couchbase.com/dotnet-sdk/current/howtos/subdocument-operations.html), I am very interested in performing "subDocument" operations for my particular use case. However, the examples on both the docs.couchbase.com site as well as here appear to be providing faulty code.

Using this set up:

  • CouchbaseNetClient version 3.0.7

  • .NET 3.1 Core framework

  • Visual studio 2019

  • Couchbase DB (version 6.0.0 build 1693)

I have successfully connected and I can "UpsertAsync" a document to a "test" bucket on our couchbase database. However, when I attempt any of the "SubDocument" procedures (exactly as documented), the code will not compile. I went so far as to attempt to compile the entire "SubDocument.cs" file (docs-sdk-dotnet/modules/howtos/examples/SubDocument.cs) included in the "howtos" folder, but it also will not compile with the setup described. Any insight would be appreciated.

Thanks @MikeDotNetty
I'll ask the .NET team to take a look. ๐Ÿ‘

@MikeDotNetty Can you post your compile errors, please?
That could help diagnose what's going wrong.

@RichardSmedley
USING THE EXAMPLE CODE (thinking this is based off version 2.7)

So in attempting to use the SubDocument.cs example code as provided there are a lot of errors, but just starting with the first block of code (the Main function):

  • Error CS0246 The type or namespace name 'ICollection' could not be found (are you missing a using directive or an assembly reference?) couchbaseTest SubDocument.cs 8 Active

  • Error CS1061 'ClusterOptions' does not contain a definition for 'WithServers' and no accessible extension method 'WithServers' accepting a first argument of type 'ClusterOptions' could be found (are you missing a using directive or an assembly reference?) couchbaseTest SubDocument.cs 13 Active

  • Error CS1729 'Cluster' does not contain a constructor that takes 1 arguments couchbaseTest SubDocument.cs 17 Active

  • Error CS1061 'ICouchbaseCollection' does not contain a definition for 'GetAwaiter' and no accessible extension method 'GetAwaiter' accepting a first argument of type 'ICouchbaseCollection' could be found (are you missing a using directive or an assembly reference?) couchbaseTest SubDocument.cs 19 Active

image

USING CODE SPECIFIC TO VERSION 3.0

Now using code that I can actually get to work (with ConnectAsync and UpsertAsync), when I try to do one of these "SubDocument" operations, I get this error:

  • Error CS1660 Cannot convert lambda expression to type 'IEnumerable' because it is not a delegate type couchbaseTest Program.cs 51 Active

image

@MikeDotNetty, thanks for reporting this.

As for the 3.0-specific example, it needs a using Couchbase.KeyValue; statement to bring in the extension method for that overload.

@RiPont That cleared up my errors. Honestly I only really care about getting the 3.0 code working. I think with that information I can proceed. MUCH APPRECIATED!

Glad to hear you are now unblocked,
We aim to update the docs sometime this month.