Ich verwende SQLite in meinem UWP-Projekt. Meine Modellklasse hat Datetime-Felder:SQLite Bigint zu Datetime in C#
public class EducationInfo
{
[SQLite.Net.Attributes.PrimaryKey, SQLite.Net.Attributes.AutoIncrement]
public int educationInfoId { get; set; }
public String Education { get; set; }
public bool Enabled { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
public int UserId { get; set; }
// Not in the DB
[Ignore]
public string FormattedStartDate { get; set; }
[Ignore]
public string FormattedEndDate { get; set; }
public EducationInfo()
{}
public EducationInfo(String edu, bool enabled, DateTime st, DateTime ed, int userId)
{
this.Education = edu;
this.Enabled = enabled;
this.StartDate = st;
this.EndDate = ed;
this.UserId = userId;
}
}
Das Problem ist, dass SQLite die Datetime Felder als bigint erstellen. Wie kann ich diese Bigint lesen und als DateTime einstellen?
`
var education = connection.Table<EducationInfo>().Where(e => e.UserId == user.userID);
foreach(var edu in education)
{
EducationInfo educationInfo = new EducationInfo();
educationInfo.StartDate = edu.StartDate;
}
Der obige Code Fehler nicht zurück, aber das Datum Wert ist falsch. `
Welche ORM verwenden Sie? – Dai
Es ist SQLite.NET-PCL – user6824563