I have an object called Product
and I want to retrieve the "Bill Of Material" for a certain product from the list of all products (stored in SQL Server). Should I first create the Product object then get the data from my repository thru a method, like this:
var productId = "1";
Product product = new Product(productId);
DataTable billOfMaterial = product.GetBillOfMaterial();
OR retrieve the data strait from a static Repository, like this:
var productId = "1";
DataTable billOfMaterial = product.GetBillOfMaterial(productId);
OR maybe like this?
var productId = "1";
DataTable BillOfMaterial = ProductRepository.GetBillOfMaterial(productId);
OR maybe when I create the Product I automatically get the Bill in the constructor of the product:
var productId = "1";
Product product = new Product(productId);
DataGrid.DataSource = product.BillOfMaterial;
I am using the MVP pattern, and don't know if it is best practice to fill object just to get the DataTable
or if I can just quickly use a static repository. What is the correct way to do it?
Aucun commentaire:
Enregistrer un commentaire