Error when querying a bucket with .NET SDK

I’m new using Couchbase.NET library, I’m executing this query on my bucket:

var myQuery = $"SELECT COUNT(DISTINCT name) AS countOfDistinctNames FROM {CouchbaseBucketHelperCustom.Bucket.Name} WHERE type='person'";
        var queryResult = CouchbaseBucketHelperCustom.Bucket.Query<int>(query);

If I declare the type instead of int for example:

private struct CountResult {
public int countOfDistinctNames { get; set; }
}

It works but I think that it should not be necessary to declare a type only for a count result is it possible to do it without declaring a CountResult?

Hi @IRobot

If you use the RAW keyword in your query, you’ll get the value by itself is read of being wrapped on the variable name.

For example:
SELECT RAW COUNT(DISTINCT name) AS countOfDistinctNames FROM {CouchbaseBucketHelperCustom.Bucket.Name} WHERE type=‘person’