0

I'm trying to access a SQLite Database with EntityFramework. When I try to query a field of type "timestamp" with LINQ I get a FormatException. I couldn't find a answer to this anyone else seems to work with regular sql queries. It may be Important that the DB is coming from an iOS app.

This is my code:

using (var db = new WorkTimesEntities())
{
    var times = db.ZDAYs.ToList();
    foreach (var item in times)
    {
       Console.WriteLine(item.ZDATEOFDAY+"\t"+item.ZDURATION+"\t"+item.ZMONTH);
    }
}
Marco Rebsamen
  • 605
  • 7
  • 30
  • Unlike forum sites, we don't use "Thanks", or "Any help appreciated", or signatures on [so]. See "[Should 'Hi', 'thanks,' taglines, and salutations be removed from posts?](http://meta.stackexchange.com/questions/2950/should-hi-thanks-taglines-and-salutations-be-removed-from-posts). – John Saunders May 25 '15 at 19:22

2 Answers2

0

In SQLlite a timestamp is in Unix time, that is the number of seconds since 1.1.1970.

Since you are getting a format exception on a query, it must be related to how you are setting the query parameter for the datetime field. For example are you sending in a string that is a formatted datetime?

If you need more help post your Linq query.

Shiraz Bhaiji
  • 64,065
  • 34
  • 143
  • 252
0

OK, these threads helped me out:

SQLite DATETIME column with Entity Framework
Explained me that I have to modify the connection string in App.config by myself.

keyword not supported data source
And this one showed me the correct syntax for the connection string.

Community
  • 1
  • 1
Marco Rebsamen
  • 605
  • 7
  • 30