次のオブジェクトがある場合:
public class Application
{
public int ApplicationId { get; set; }
public string Name { get; set; }
public virtual ICollection<TestAccount> TestAccounts { get; set; }
}
public class TestAccount
{
public int TestAccountId { get; set; }
public int ApplicationId { get; set; }
public string Name { get; set; }
public virtual Application Application { get; set; }
}
EF マッピングは次のようになります。
modelBuilder.Entity<Application>()
.HasMany(a => a.TestAccounts)
.WithRequired(t => t.Application)
.WillCascadeOnDelete(false);
コードの一部で、Application のデータを取得し、TestAccount データを返すようにします。
コードの別の部分で、アプリケーションのデータを取得し、TestAccount データを返さないようにします。
LINQ または他の方法でこれを実現する方法はありますか?