In my C# VS2015 Windows 10 Universal App, I cannot create a DateTime field in the database schema. It creates a bigint instead. I have other tables that have created a DateTime field with no problems.
Here is one example: (see the GameDate field)
Table [Results] Fields: 17 [Season]: nvarchar(100) [Id]: INTEGER [HomeTeamName]: nvarchar(100) [OppTeamName]: nvarchar(100) [GameDate]: datetime
Foreign Keys: 0
Indexes: 1
[] PRIMARY
[Id] AUTOINCREMENT
Triggers: 0
Unique constraints: 0
Check constraints: 0
private void AddUserButton_Click(object sender, RoutedEventArgs e)
{
User user = new User();
user.Name = "User1";
user.GameDate = Convert.ToDateTime("2015-09-02");
var path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "BaseBallOU.db");
using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path))
{
conn.Insert(user);
}
}
private void CreateTablesButton_Click(object sender, RoutedEventArgs e)
{
var path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "BaseBallOU.db");
using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path))
{
conn.CreateTable<User>();
conn.CreateTable<TeamX>();
}
}
}
public class User
{
[SQLite.AutoIncrement, SQLite.PrimaryKey]
public int id { get; set; }
public DateTime GameDate { get; set; }
public string Name { get; set; }
}
public class TeamX
{
[SQLite.AutoIncrement, SQLite.PrimaryKey]
public int id { get; set; }
public string TeamName { get; set; }
public DateTime GameDate { get; set; }
}
Below is what gets created in the tables:
Table [TeamX]
Fields: 3
[id]: integer
[TeamName]: varchar
[GameDate]: bigint
Foreign Keys: 0
Indexes: 0
Triggers: 0
Unique constraints: 0
Check constraints: 0
I'm using the following references:
sqlite-net-pcl SQLite.Net-PCL SQLite for Universal App Platform
Aucun commentaire:
Enregistrer un commentaire