title: Find difference between date in table and midnight (ASP.NET MVC)
body: <p>I have table with data</p>
  
  <p>Here is Model</p>
  
  <pre><code>public partial class Logging
  {
      public string Imei { get; set; }
      public Nullable&lt;System.DateTime&gt; CurDateTime { get; set; }
      public Nullable&lt;System.DateTime&gt; GPSDateTime2 { get; set; }
      public Nullable&lt;decimal&gt; Latitude2 { get; set; }
      public Nullable&lt;decimal&gt; Longitude2 { get; set; }
      public string Speed { get; set; }
      public Nullable&lt;int&gt; Datatype { get; set; }
      public int Id { get; set; }
      [NotMapped]
      public TimeSpan? FirstStartDifference { get { return CurDateTime - DateTime.Today; } }
      [NotMapped]
      public int coeff = 2;
  }
  </code></pre>
  
  <p>I need to find data between  CurDateTime and midnight in minuutes</p>
  
  <p>But <code>public TimeSpan? FirstStartDifference { get { return CurDateTime - DateTime.Today; } }</code> not right because <code>DateTime.Today</code> is today and I get difference in <code>-</code>.</p>
  
  <p>On Controller I do it like this</p>
  
  <pre><code>   public JsonResult GetStops()
      {
          using (var ctx = new GoogleMapTutorialEntities())
          {
              var firstitem = ctx.Loggings.Where(x =&gt; x.Datatype == 1).AsEnumerable().Select(
                  x =&gt; new
                  {
                      lng = x.Longitude2,
                      lat = x.Latitude2,
                      difference = (int)(x.FirstStartDifference?.TotalMinutes ?? -1) * x.coeff
                  }).FirstOrDefault();
  
              return Json(firstitem, JsonRequestBehavior.AllowGet);
          }
      }
  </code></pre>
  
  <p>How I can calculate difference correctly</p>