クラスFoodsがあるとしましょう
public class FoodsContext : DbContext, IUnitOfWork
{
public DbSet<Consumer> Consumers {get; set;}
}
クラスFruitsがあります
public class FruitsContext: FoodsContext
{
public DbSet<Price> Prices {get; set;}
}
次に、私のリポジトリにあるとしましょう
public class SampleRepository
{
private readonly FruitsContext _dbFruits = new FruitsContext();
public void foo()
{
_dbFruits.Prices.doanything;
//how can i use Consumers table that has been set in Foods class
}
}
私のリポジトリ クラスでは、 Foodクラスのインスタンスを作成せずに、 Consumersテーブルの値にアクセスしたいと考えています。どうやってやるの?
これは何かのプロジェクトで見たことがありますが、今はよく覚えていません。誰かが何かを提案できますか?