Mech0z
Mech0z

Reputation: 3647

Cant deserialize inherited object with Mongo c# driver

I am using AspNetCore.Identity.MongoDB nuget package to get some Asp.Net Identity features into my project.

Then I want to extend the MongoIdentityUser that exists with the User type I originally created for my project, so I tried to inherit from that class and create my User Class that has MongoIdentityUser as its base class.

If I try to query my collection where I have one MongoIdentityUser stored and try to deserialize it into MongoIdentityUser I get that one item out, so success.

But if I try to deserialize it into My User which is just an inherited class of MongoDBUser I get this exception: Exception

Is it not possible to extent a class like that I want? Also the exception is pretty useless, not sure why its not giving me a more detailed exception

The json object looks like this

{
    "_id": "[email protected]",
    "userName": "[email protected]",
    "normalizedUserName": "[email protected]",
    "email": {
        "value": "[email protected]",
        "confirmationRecord": null,
        "normalizedValue": "[email protected]"
    },
    "phoneNumber": null,
    "passwordHash": "xxx",
    "securityStamp": "87242bb7-2a09-4905-ba61",
    "isTwoFactorEnabled": false,
    "claims": [],
    "logins": [],
    "accessFailedCount": 0,
    "isLockoutEnabled": true,
    "lockoutEndDate": null,
    "createdOn": {
        "instant": {
            "$date": "2016-11-13T17:05:59.487Z"
        }
    },
    "deletedOn": null
}

Upvotes: 1

Views: 836

Answers (1)

Mech0z
Mech0z

Reputation: 3647

Fixed in the latest release of the framework https://github.com/tugberkugurlu/AspNetCore.Identity.MongoDB/releases/tag/1.0.0-rc3

Upvotes: 1

Related Questions