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();
}