SQLiteNetExtensions 多个相同类型的 ManyToOne 关系

SQLiteNetExtensions multiple ManyToOne relations of same type

我正在尝试 xamarin 应用程序...我需要 sqlite 数据库...包含 3 tables...用户、帐户和交易...帐户的 table似乎:

[Table(nameof(Account))]
class Account
{
    [PrimaryKey,AutoIncrement]
    public int Id { get; set; }

    public string Name { get; set; }

    [ForeignKey(typeof(User))]
    public int UserId { get; set; }

    public double Balance { get; set; }

    [ManyToOne]
    public User User { get; set; }

    [OneToMany(CascadeOperations = CascadeOperation.All)]
    public List<Transaction> Transactions { get; set; }
}

我认为直到这里都没有问题... 但是在事务 table 中有两列,FirstAccountIdTargetAccountId,所以我喜欢这样:

[Table(nameof(Transaction))]
class Transaction
{
    [PrimaryKey,AutoIncrement]
    public int Id { get; set; }

    [ForeignKey(typeof(Account))]
    public int TargetAccountId { set; get; }

    [ForeignKey(typeof(Account))]
    public int FirstAccountId { get; set; }

    public DateTime DateOfTransaction { get; set; }

    [ManyToOne()]
    public Account Account1 { get; set; }

    [ManyToOne()]
    public Account Account2 { get; set; }`
}

我怎样才能让 Account1FirstAccountId 的帐户,Account2TargetAccountId

的帐户

根据ManyToOne(see here)的源代码,它需要一个string foreignKey作为参数。我没有在文档中找到任何关于它的信息,但我假设你可以使用这个参数明确指定一个外键,尽管我没有在文档中找到任何关于它的信息

[ManyToOne(nameof(FirstAccountId))]
public Account Account1 { get; set; }

[ManyToOne(nameof(TargetAccountId))]
public Account Account2 { get; set; }