我有我的FileDownloadContentModel
類延伸IBaseContentModel
源碼網是不能從父類認主鍵
public class FileDownloadContentModel : IBaseContentModel
{
public string url { get; set; }
public string filename { get; set; }
public int downloadPercentage { get; set; }
public DateTime dateDownloaded { get; set; }
public byte[] content { get; set; }
}
這裏是IBaseContentModel
:
public class IBaseContentModel
{
[PrimaryKey]
public int id { get; set; }
public IBaseContentModel()
{
id = GenerateID();
}
protected static int GenerateID()
{
DateTime value = DateTime.UtcNow;
//create Timespan by subtracting the value provided from the Unix Epoch
TimeSpan span = (value - new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime());
//return the total seconds (which is a UNIX timestamp)
return (int)span.TotalSeconds;
}
}
出於某種原因源碼網無法在獲取表映射時識別主鍵。它聲明主鍵是空的。如果我將id(主鍵)直接包含在我的FileDownloadContentModel
類中,則它可以將主鍵識別爲id。
這是一個已知的bug或我在這裏做什麼了嗎?任何幫助表示讚賞,謝謝!
修訂
我看着它更多的現在和我的一個愚蠢的錯誤。我有sqlite的兩個「實例」出於某種原因,IBaseContentModel被使用SQLite比FileDownloadContentModel的不同實例,這就是爲什麼主鍵是不被認可(因爲它不是來自同一個實例)。而實例我的意思是兩個完全不同的sqlite.cs文件與不同的軟件包名稱。
我不能跟你上面給出確切的代碼來重現問題。當我嘗試插入/刪除時,SQLite-Net找到主鍵。是否有可能您的基地實際上是一個界面,正如@RoadBump在他的回答中所建議的那樣? –
感謝您對此進行調查x。我現在更加關注它,這是我的一個愚蠢的錯誤。我有sqlite的兩個「實例」出於某種原因,IBaseContentModel被使用SQLite比FileDownloadContentModel的不同實例,這就是爲什麼主鍵是不被認可(因爲它不是來自同一個實例)。而實例我的意思是兩個完全不同的sqlite.cs文件與不同的軟件包名稱。 – KrispyDonuts