title: EntityFramework Oracle C# - can't compare Timestamp with Datetime in where Clause
body: <p>I am using an Oracle Database and the Nuget Packages </p>
  
  <ul>
  <li>Oracle ManagedDataAccess v12.2.1100</li>
  <li>Oracle.ManagedDataAccess.EntityFramework v12.2.1100</li>
  <li>EntityFramework v6.0.0</li>
  </ul>
  
  <p>In the Oracle Database there is a field defined with Timestamp(6).
  As I am Using Database first, this gets converted into DateTime.
  So far so good.</p>
  
  <p>Now I am going to insert the current timestamp into the table:</p>
  
  <pre><code>DateTime dateTime = DateTime.Now;
  //only 3 parts of milisec
  DateTime zeitStempel = dateTime.AddTicks(-1 * dateTime.Ticks % 10000);
  
  using (Entities ctx = new Entities(DBConnect.BuildConnectionString(_bedien, "ModelJobLog")))
  {
      JOB job = (from e in ctx.JOB
                 where e.PROGNAME == progName
                 select e).FirstOrDefault();
  
      JOBLAEUFE lauf = new JOBLAEUFE();
      lauf.JOBID = job.JOBID;
      lauf.JOB = job;
      lauf.LETZTSTART = zeitStempel;
  
      ctx.JOBLAEUFE.Add(lauf);
  
      ctx.SaveChanges();
  }
  </code></pre>
  
  <p>Everything is fine, in my Field i have the value:
  "26.10.17 07:39:53,381000000"</p>
  
  <p>Now i remember this dateTime (variable zeitStempel) and now i am going for a search for it in this table.
  So i still have the same dateTime object and search now for the value in the Database and want to set the current dateTime in another field:</p>
  
  <pre><code>using (Entities ctx = new Entities(DBConnect.BuildConnectionString(_bedien, "ModelJobLog")))
  {
      try
      {
          Oracle.ManagedDataAccess.Types.OracleTimeStamp tmstmp = zeitStempel;
          JOBLAEUFE lauf = (from e in ctx.JOBLAEUFE
                            join j in ctx.JOB on e.JOBID equals j.JOBID
                            where j.PROGNAME == progName
                            &amp;&amp;( e.LETZTSTART.Equals(zeitStempel)
                                || (e.LETZTSTART.Year == zeitStempel.Year
                                &amp;&amp; e.LETZTSTART.Month == zeitStempel.Month
                                &amp;&amp; e.LETZTSTART.Day == zeitStempel.Day
                                &amp;&amp; e.LETZTSTART.Hour == zeitStempel.Hour
                                &amp;&amp; e.LETZTSTART.Minute == zeitStempel.Minute
                                &amp;&amp; e.LETZTSTART.Second == zeitStempel.Second
                                ))
                            select e).FirstOrDefault();
  
          lauf.LETZTEND = DateTime.Now;
          ctx.SaveChanges();
      }
      .
      .
      .
  }
  </code></pre>
  
  <p>If I compare in the where clause <em>with</em> the Seconds i never get the value of the DB. If i however leave the Seconds out of the where clause, he finds the database record. But of course the minute alone is not precise enough.</p>
  
  <p>Both, e.LETZTSTART and zeitStempel are from DateTime and if I check in debugging all properties are the same.</p>
  
  <p>Kind regards,</p>