tugberkugurlu / AspNetCore.Identity.MongoDB

MongoDB Data Store Adaptor for ASP.NET Core Identity
MIT License
229 stars 69 forks source link

Custom properties are serialized to database as PascalCase #38

Closed tugberkugurlu closed 7 years ago

tugberkugurlu commented 7 years ago

For

public class MyIdentityUser : MongoIdentityUser
{
    public MyIdentityUser(string userName) : base(userName)
    {
    }

    public string MyCustomThing { get; set; }
}

We get this:

image

Initial hunch tells me that changing IsConventionApplicable to below can fix the issue:

        private static bool IsConventionApplicable(Type type) =>
            type.IsAssignableFrom(typeof(MongoIdentityUser))
                || type.IsAssignableFrom(typeof(MongoUserClaim))
                || type.IsAssignableFrom(typeof(MongoUserContactRecord))
                || type.IsAssignableFrom(typeof(MongoUserEmail))
                || type.IsAssignableFrom(typeof(MongoUserLogin))
                || type.IsAssignableFrom(typeof(MongoUserPhoneNumber))
                || type.IsAssignableFrom(typeof(ConfirmationOccurrence))
                || type.IsAssignableFrom(typeof(FutureOccurrence))
                || type.IsAssignableFrom(typeof(Occurrence));

On the other hand, I am not entirely sure if this is a good thing since the user can use the derived classes to store elsewhere. If they are bothered with this, they can always apply their own registration. So, I am leaning towards leaving the current behaviour as is.