MVC.NET milliseconds get lost when using Html.hidden on a DateTime LastUpdated column for version tracking

后端 未结 5 1992
小鲜肉
小鲜肉 2021-01-12 15:30

Question in short:

How tot do this in MVC.NET?

Question in long version:

Im trying to use a DateTime column in a SQL Table for version tracking (this

5条回答
  •  不要未来只要你来
    2021-01-12 15:57

    You need to use the DateTime.Ticks property to get the milliseconds.

    If you are using a ViewModel you can define a property on the it that stores the DateTime ticks. For example:

    public long LastUpdateTick { get; set; }
    

    When you map your entity to your model and back you can do the conversion between DateTime and ticks in the mapping code.

    Your view can then bind to the LastUpdateTick property. This will allow you to still use lambda expressions for the binding if you wanted to.

提交回复
热议问题