0
我有以下表處理財產不直接映射到列的數據庫上
客戶表和產品表
ID
Name
ClientProduct表
ID
ClientID
ProductID
產品類
private int id;
public int ID
{
get { return id; }
set { id = value; }
}
protected string name;
public Product() { }
public Product (string name)
{
this.name = name;
}
public Product (string name)
{
this.name = name;
}
public string Name
{
get { return name; }
set { name = value; }
}
Client類
private int id;
public int ID
{
get { return id; }
set { id = value; }
}
protected string name;
public Client() { }
public Client (string name)
{
this.name = name;
}
public Client (string name)
{
this.name = name;
}
public string Name
{
get { return name; }
set { name = value; }
}
ClientProduct類
protected Client client;
protected Product product;
public ClientProduct () { }
public ClientProduct (Client client, Product product)
{
this.client= client;
this.product= product;
}
public Client client {
get { return client; }
set { client= value; }
}
public Product product {
get { return product; }
set { product= value; }
}
我怎樣才能做到在petaPOCO以下?
public static System.Collections.Generic.IList<ClientProduct> LoadForClient(Client client)
{
if (null != client)
return Load("ClientID = " + client.ID);
else
return null;
}
,這樣我可以有所有產品的客戶端,我將在我的觀點後來被用作
private void LoadProducts(Client client)
{
Products = ClientProduct.LoadForClient(client)
.Select(x => x.Product.Name)
.OrderBy(x => x).ToArray();
}