0
リポジトリパターンを使用してASP.NET MVCでの複数のテーブルからデータを取得) { this.Products = new HashSet(); }Entity Frameworkの私は私のモデルに関連した2つのクラスを持っている
public int ProviderId { get; set; }
public string OfficialName { get; set; } // nome usado no licenciamento
public string PopularName { get; set; } // nome popular, mais conhecido
public int Nuit { get; set; } //identificacao tributaria
public EstablishmentCategory EstablishmentCategory { get; set; } // tipo de estabelecimento
public HalalState HalalState { get; set; }
public DateTime? LastUpdate { get; set; } // date e hora do registo
public ICollection<Product> Products { get; set; } // lista de produtos halal
}
私はカミソリのエンジンを使用してページに表示するために、そのプロバイダ名と一緒に製品をロードしようとしています。ような何か:
Product Name (from table A) | Provider Name (from table B)
Soft drink | Coca-Cola
Chips | Lays
クラスProductsRepository
の製品を取得する方法:
public ICollection<Product> ReadAll()
{
return context.Products.ToList();
}
私はProduct
の他のプロパティと一緒にそれを表示するためには、Provider
クラスのOfficialName
プロパティに移動する方法が必要ですビューで。