The serializer does not work

I use CouchbaseNetClient version 3.5.2

    [JsonObject(Title = "identityUser")]
    public class ApplicationUser : IdentityUser
    {
        [JsonProperty("id")]
        public override string Id { get; set; }

        [JsonProperty("userName")]
        public override string UserName { get; set; }

        [JsonProperty("normalizedUserName")]
        public override string NormalizedUserName { get; set; }

        [JsonProperty("email")]
        public override string Email { get; set; }

        [JsonProperty("normalizedEmail")]
        public override string NormalizedEmail { get; set; }

        [JsonProperty("emailConfirmed")]
        public override bool EmailConfirmed { get; set; }

        [JsonProperty("passwordHash")]
        public override string PasswordHash { get; set; }

        [JsonProperty("securityStamp")]
        public override string SecurityStamp { get; set; }

        [JsonProperty("concurrencyStamp")]
        public override string ConcurrencyStamp { get; set; }

        [JsonProperty("phoneNumber")]
        public override string PhoneNumber { get; set; }

        [JsonProperty("phoneNumberConfirmed")]
        public override bool PhoneNumberConfirmed { get; set; }

        [JsonProperty("twoFactorEnabled")]
        public override bool TwoFactorEnabled { get; set; }

        [JsonProperty("lockoutEnd")]
        public override DateTimeOffset? LockoutEnd { get; set; }

        [JsonProperty("lockoutEnabled")]
        public override bool LockoutEnabled { get; set; }

        [JsonProperty("accessFailedCount")]
        public override int AccessFailedCount { get; set; }
    }
        public async Task<ApplicationUser> FindByNameAsync(string normalizedUserName, CancellationToken cancellationToken)
        {
            var query = $"SELECT * FROM `{_bucketName}`.`{_scopeName}`.`{_collectionName}` WHERE normalizedUserName = $1";
            var result = await _bucket.Cluster.QueryAsync<ApplicationUser>(query, new QueryOptions().Parameter(normalizedUserName));
            ApplicationUser applicationUser = await result.Rows.FirstOrDefaultAsync();

            var result2 = await _bucket.Cluster.QueryAsync<dynamic>(query, new QueryOptions().Parameter(normalizedUserName));
            dynamic applicationUser2 = await result2.Rows.FirstOrDefaultAsync();


            return applicationUser;
         
        }

only applicationUser2 has data and applicationUser not.
What am i doing wrong?

Is the only difference that applicationUser is ApplicationUser while applicationUser2 is dynamic?

I suspect that the select should be

select coll.* from {_bucketName}.{_scopeName}.{_collectionName} coll …

With just select *, the rows will.have an extra encapsulation.

This was the solution, thank you.

1 Like

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