c# - DateTime to Datetime2 -


I have started using the structure of the institution and after researching, I found that the unit framework is only the date format format date 2 accepts.

What is the best way to change the date time picker in Datetime2 format

I currently do the following

  string strCastFrom = this .dtCastFrom.Value ("00") + "-" + this.dtCastFrom.Value.Month.ToString ("00") + "-" + this.dtCastFrom.Value.Day.ToString ("00") + "T00 : 00: 00 ";  

Is Better Than Datetime to Convert Datetime?

do not perform any string conversion. Just use

  date time value = dtCastFrom.Value;  

The unit framework should be careful to get data from the database. You do not want represent a string, and through is not a reason to represent a string representation. This is not just a case for EF, it is a general theory.


Comments