When I insert data into my SQLite connection, one of the properties on the data contract is a datetime (which I fill using Datetime.Now).
The insert seems to go fine. But when I get the same data back from the database, the millisecond info on the datetime object is zeroed out. I've checked and the millisecond data is present in the datetime object when I insert it into the database.
Am I supposed to format the datetime object before I insert into the database? I'm not sure why the millisecond data isn't being returned when I poll the database.
Here's the Get & Insert methods I'm using
public IEnumerable<SensorData> GetSensorDataForSession(int sessionId)
{
using (var db = new SQLite.SQLiteConnection(base.DbPath))
{
var results = db.Table<Entities.SensorData>().Where(x => x.SessionId == sessionId).ToList();
return results.Select(x => (SensorData)x).ToList();
}
}
public void SaveSensorData(SensorData data)
{
using (var db = new SQLite.SQLiteConnection(base.DbPath))
{
db.Insert((Entities.SensorData)data);
}
}
The SensorData object looks like this
public class SensorData
{
[PrimaryKey, AutoIncrement]
public int ID { get; set; }
public int SessionId { get; set; }
public DateTime Timestamp { get; set; }
public double AccelerometerXAxis { get; set; }
public double AccelerometerYAxis { get; set; }
public double AccelerometerZAxis { get; set; }
public double GyroscopeXAxis { get; set; }
public double GyroscopeYAxis { get; set; }
public double GyroscopeZAxis { get; set; }
public double Speed { get; set; }
public double Altitude { get; set; }
public double Bearing { get; set; }
public double Longitude { get; set; }
public double Latitude { get; set; }
public double Accuracy { get; set; }
}