mardi 25 février 2020

Get Values from inherited when base type is given back

Situation: IdentityUser is inherited by AppUser.

AppUser has a few properties more.((int)ExClientNr and (string)Category)

On top

UserManager <IdentityUser> userManager

request

var user = await userManager.FindByEmailAsync(Input.Email);

When I hover over user (of type IdentityUser) in runtime, I see all AppUser properties with values in the list.

But when I type

var exClientNr = User.ExClientNr; 

the field ExClientNr or Category is not recognized in the intellisense.All fields of IdentityUser are of cause.

User.Getype() gives me {Name="AppUser" FullName="namespace.Models.AppUser"} so it is even aware of his type.

Question: Can someone tell me how to get the value from those extra properties from this object.





Aucun commentaire:

Enregistrer un commentaire