I am getting a response from a json api and deseralizing this into a corresponding object as below and saving the results into sqlite db.
[Table("Product")]
public class Fields
{
[PrimaryKey]
public int id { get; set; }
public string status { get; set; }
[Indexed]
[Column("CategoryId")]
public int category { get; set; }
}
in the api, it is called as category but I want to save as CategoryId into my sqlite table.
var conn = new SQLiteConnection("mydatabase.db3");
conn.CreateTable<Api.Fields>();
conn.InsertAll(response);
If I try to create table no problem, it gets created with CategoryId but when I try to insert results, it will complain with the message below,
SQLite.SQLiteException was unhandled by user code
HResult=-2146233088 Message=Constraint Source=SQLite-net
StackTrace: at SQLite.PreparedSqlLiteInsertCommand.ExecuteNonQuery(Object[] source) at SQLite.SQLiteConnection.Insert(Object obj, String extra, Type objType) at SQLite.SQLiteConnection.Insert(Object obj)
How can I set that mapping? I see there are some overloads like getmappings or tablemappings but I cant find any usage or syntax information how to use it?
Aucun commentaire:
Enregistrer un commentaire