Uploaded image for project: 'Couchbase .NET client library'
  1. Couchbase .NET client library
  2. NCBC-2275

Calling Buck.ListSize fails if list already has a value

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • None
    • 2.7.15
    • library
    • None
    • Windows10 Home developer machine
    • 1

    Description

      When checking the list size with Bucket.ListSize(key) I am getting an error of “Unable to cast object of type ‘System.String’ to type ‘System.Collections.Generic.List`1[System.Object]’” when attempting to get the size of a list using Bucket.ListSize(key) .  This happens when there is already an item in the list, which I can check for in the web portal.  

      public override bool ListAppend(string key, object value)
              {
                  if (string.IsNullOrWhiteSpace(key))
                      throw new ArgumentNullException(nameof(key), @"The key parameter must be string value with length greater than zero.");            if (value == null)
                      throw new ArgumentNullException(nameof(value), @"The value object parameter must not be null.");            try
                  {
                      IResult result;                if (Bucket.ListSize(key).Value == 0)
                      {
                          result = Bucket.Upsert(key, "[]");
                          if (!result.Success) throw result.Exception;
                      }                result = Bucket.ListAppend(key, value, false);                if (result.Success) return true;
                      throw result.Exception;
                  }
                  catch (Exception ex)
                  {
                      //Logger.Error("[CouchbaseCacheProvider] Error while calling ListAdd", ex);
                      return false;
                  }
              }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            jmorris Jeff Morris
            jrwallace96 James Wallace
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty