This is my definition column in my database.
I have a problem with DateTime
in C# and the value that is being saved into my database SQL Server
.
When the applications sends: 2019-06-14 17:10:39.0192950
Saves into SQL Server
this: 2019-06-14 17:10:39.0200000
.
And When I need to check if the file already exists in my database using the following function:
protected Func<DateTime?, DateTime?, bool> TimeEquals = (x, y) =>
x.Value.Hour == y.Value.Hour
&& x.Value.Minute == y.Value.Minute
&& x.Value.Second == y.Value.Second && x.Value.Millisecond == y.Value.Millisecond;
That is my code when I insert the values into my SQL Server
database:
foreach (var parameter in parameters)
{
command.Parameters.Add(new SqlParameter(
parameter.Label,
parameter.Value
));
}
I start having problems loosing precision. What is the best way to not loose precision when dealing with dates between C#
and SQL Server
?