locked
Please explain: LockoutEndDateUtc vs IUserLockoutStore.SetLockoutEndDateAsync RRS feed

  • Question

  • User-217557848 posted

    I need some explanation concerning why LockoutEndDateUtc is a Nullable<DateTime>, whereas the SetLockoutEndDateAsync, either via IUserLockoutStore or via UserManager, work with a DateTimeOffset.

    The main concern is, whatever my underlying model does, the interceding service layers work with DateTimeOffset. I need to know what that means in terms of the model LockoutEndDateUtc.

    Microsoft docs are silent on the ramifications, as far as I can tell.

    Thank you...

    Monday, February 29, 2016 12:59 PM

All replies

  • User-217557848 posted

    DateTime and DateTimeOffset in .NET: Good practices and common pitfalls was helpful in shedding some light on the subject.

    However, would be helpful to learn from an Identity perspective, as well, because the IdentityUser is using Nullable<DateTime>, which leads me to believe there are some magic calculations happening within one or some of the manager, service level code in the guts of Identity Framework.

    Thank you...

    Monday, February 29, 2016 1:07 PM
  • User-217557848 posted

    Another key question is, why would IdentityUser have a Nullable<DateTime> when the manager/store layers work with a non-nullable DateTimeOffset? Makes no sense whatsoever. Or, alternatively, that implies that the DateTimeOffset is only get/set mutated when lockout has occurred?

    Monday, February 29, 2016 1:15 PM
  • User1686483761 posted

    Hi mwpowellhtx,

    Nullable<DateTime> when the manager/store layers work with a non-nullable DateTimeOffset?

    I'm not sure, but you could try to convert a Nullable<DateTime> variable to a non-nullable DateTimeOffset and check if it's ok.

    https://msdn.microsoft.com/en-us/library/system.datetimeoffset%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396

    Wednesday, March 2, 2016 1:16 AM