title: Unable to cast the type 'System.Int32' to type'System.Object'. LINQ to Entities only supports casting EDM primitive or enumeration types
body: <p>Hi I believe this question was already a 100 times on StackOverFlow, but I did not manage to fix my issue. This is code line that makes me a trouble  </p>
  
  <pre><code> DatumSnimanja = (x.VrijemeSnimanja != null) ? ((DateTime)x.VrijemeSnimanja).Day + "." + ((DateTime)x.VrijemeSnimanja).Month + "." + ((DateTime)x.VrijemeSnimanja).Year : null,
  </code></pre>
  
  <p>Please how to fix this.</p>
  
  <p>full code</p>
  
  <pre><code>     var result = resultVideoKlipBaseInfo.Select(x =&gt; new
              {
                  x.IDvideoKlip,
                  x.LokacijaHDD,
                  x.NazivVideoKlipa,
                  x.Snimatelj.IDsnimatelj,
                  x.Snimatelj.Ime,
                  x.Snimatelj.Prezime,
                  x.Snimatelj.Storno,
                  DatumSnimanja = (x.VrijemeSnimanja != null) ? ((DateTime)x.VrijemeSnimanja).Day + "." + ((DateTime)x.VrijemeSnimanja).Month + "." + ((DateTime)x.VrijemeSnimanja).Year : null,
                  SatIMinutaSnimanja = (x.VrijemeSnimanja != null) ? ((DateTime)x.VrijemeSnimanja).Hour + ":" + ((DateTime)x.VrijemeSnimanja).Minute : null,
                  x.VrijemeSnimanja,                          
                  x.VrijemeTrajanjaKlipa
  
              });
              return Ok(result);
  </code></pre>
  
  <p>With this code I am fetching DateTime from database, and casting it to string format from DateTime format.</p>
  
  <p>I want to have from this 2016-12-31 00:00:00.000 something like this 31.12.2016</p>
  
  <p>Thank you all for reading this question :)</p>