Evi*_*eer 3 c# sqlite android xamarin.ios xamarin
我正在尝试使用Xamarin.Android创建一个简单的本地SQLite数据库.代码是:
string folder = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
SQLiteConnectiondb = new SQLiteConnection (Path.Combine (folder, "Experimental.db"));
db.CreateTable<Employee>();
Run Code Online (Sandbox Code Playgroud)
我的员工课程是:
[Table("Employees")]
public class Employee
{
[PrimaryKey, AutoIncrement]
int Id { get; set; }
string Name { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
每当代码到达db.CreateTable时,我得到的异常是:
SQLite.SQLiteException: near ")": syntax error
at at SQLite.SQLite3.Prepare2 (intptr,string) <IL 0x0002c, 0x00160>
at at SQLite.SQLiteCommand.Prepare () <IL 0x00011, 0x0008f>
at at SQLite.SQLiteCommand.ExecuteNonQuery () <IL 0x00013, 0x000b3>
at at SQLite.SQLiteConnection.Execute (string,object[]) <IL 0x00041, 0x001ab>
at at SQLite.SQLiteConnection.CreateTable (System.Type,SQLite.CreateFlags) <IL 0x000a4, 0x005cb>
at at SQLite.SQLiteConnection.CreateTable<Core.Employee> (SQLite.CreateFlags) <0x00063>
Run Code Online (Sandbox Code Playgroud)
对于我没有经验的人来说,这看起来像是一个与SQLite本身相关的问题.有没有其他人面对这个,如果是这样 - 你的工作是什么?
使Employee类的属性公开,以便SQLite在为表创建列时可以看到它们:
[Table("Employees")]
public class Employee
{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
public string Name { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2196 次 |
| 最近记录: |