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;
}
}
何らかの理由で、sqlite-net はテーブル マッピングを取得するときに主キーを認識できません。主キーがnullであることを示しています。FileDownloadContentModel
クラスにID(主キー)を直接含めると、主キーをIDとして認識できます。
これは既知のバグですか、それともここで何か間違ったことをしていますか? どんな助けでも大歓迎です、ありがとう!
更新しました
私は今それをもっと調べましたが、それは私の愚かな間違いです. sqlite の 2 つの「インスタンス」があり、何らかの理由で IBaseContentModel が FileDownloadContentModel とは異なる sqlite のインスタンスを使用していたため、主キーが認識されませんでした (同じインスタンスからのものではないため)。たとえば、パッケージ名が異なる 2 つの完全に異なる sqlite.cs ファイルを意味します。