サーバークラスを他のクラスの子としてデータベースを作成しています。外部キーでの書き込みは正常に機能しますが、データを取り戻そうとするとエラーがスローされます:
タイプ 'SQLiteNetExtensions.Exceptions.IncorrectRelationshipException' の未処理の例外が SQLiteNetExtensions.dll で発生しました
追加情報: MatchDetail.timeline: OneToOne 関係の少なくとも 1 つのエンティティには外部キーが必要です
これは私の作成コードです:
SQLiteConnection db = new SQLiteConnection(new SQLite.Net.Platform.Win32.SQLitePlatformWin32(), "Matches.db3");
db.CreateTable<ParticipantIdentity>();
db.CreateTable<MatchDetail>();
db.CreateTable<Timeline>();
db.InsertWithChildren(md, true);
var m = db.GetWithChildren<MatchDetail>(matchId, true);
そして私のクラス:
[Table("Matches")]
public class MatchDetail
{
[PrimaryKey]
public long matchId { get; set; }
public int mapId { get; set; }
[JsonConverter(typeof(DateTimeConverterFromLong))]
public DateTime MatchCreation { get; set; }
public long matchDuration { get; set; }
public MatchMode matchMode { get; set; }
public MatchType matchType { get; set; }
public string matchVersion { get; set; }
public string platformId { get; set; }
public Queuetype queueType { get; set; }
public Region region { get; set; }
public Season season { get; set; }
[ForeignKey(typeof(Timeline), Name = "TimelineId"), Indexed]
public int timelineId { get; set; }
[OneToOne("TimelineId", CascadeOperations = CascadeOperation.All)]
public Timeline timeline { get; set; }
[ForeignKey(typeof(ParticipantIdentity), Name = "ParticipantId"), Indexed]
public int participantIdentitiesId { get; set; }
[ManyToOne("ParticipantId", CascadeOperations = CascadeOperation.All)]
public List<ParticipantIdentity> participantIdentities { get; set; }
}
他のクラスは単なるIDとその他の基本的なタイプです。私はこれを解決しようとしましたが、うまくいきません。
編集:
[ForeignKey(typeof(ParticipantIdentity))]
public int participantIdentitiesId { get; set; }
[OneToMany(CascadeOperations = CascadeOperation.All)]
public List<ParticipantIdentity> participantIdentities { get; set; }
エラーあり:
タイプ 'SQLiteNetExtensions.Exceptions.IncorrectRelationshipException' の未処理の例外が SQLiteNetExtensions.dll で発生しました
追加情報: MatchDetail.participantIdentities: OneToMany 関係の外部キーが見つかりません