私はこのようなものを持っています: (疑似コード)
public class Author
{
int id;
public List<Thread> Threads;
public List<ThreadPoints> ThreadPointses;
}
public class Thread
{
int id;
public List<ThreadPoints> ThreadPointses;
}
public class ThreadPoints
{
int id;
int Points;
}
そして、上記が正しいかどうかはわかりませんが、指定された作成者が指定されたスレッドで持っているポイント数を取得したいと思います。ThreadPoints.Thread_id
物理的にデータベースにある場合でも、アクセスできないため、直接呼び出すことはできません。モデルを変更する必要がありますか、それとも便利な方法を知らないのでしょうか?
基本的に、私のモデルは次のようになります。
public class Account
{
[Key]
public Guid AccountId { get; set; }
public string UserName { get; set; }
public List<Post> Posts { get; set; }
public List<Post> ModifiedPosts { get; set; }
public List<Thread> Threads { get; set; }
public List<ThreadPoints> ThreadPointses { get; set; }
public List<Thread> LastReplied { get; set; }
public int Points { get; set; }
}
public class Thread
{
[Key]
public int Id { get; set; }
public List<ThreadPoints> ThreadPointses { get; set; }
public List<Post> Posts { get; set; }
public int CurrentValue { get; set; }
public int NumberOfPosts { get; set; }
public int TotalValue { get; set; }
public int Views { get; set; }
public string Title { get; set; }
public DateTime DateCreated { get; set; }
}
public class ThreadPoints
{
[Key]
public int Id { get; set; }
public int Points { get; set; }
}
そして、私が必要としているのは、ユーザーがスレッドを作成するとき、彼はそれにいくらかのポイントを与えることです。次のアクションでは、(データベースから) その量のポイントを取得し、それを増やしたいと考えています。しかし、入力情報としてスレッドIDしかありません。
あなたの答えは良いかもしれませんが(私が実装しようとしている限り)、とにかく、このモデルについてはわかりません。モデルに手動で外部キーを追加する必要があるのでしょうか? 確かに簡単ですが、データベースに2つの外部キーがあります...