上のカラムに直接マップされない性質を扱う、私は以下の表データベース
クライアントテーブルおよび製品表
ID
Name
ClientProduct表
ID
ClientID
ProductID
Productクラス
を持っています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クラスIはpetaPOCOに次の操作を行うことができますどのように
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; }
}
?
public static System.Collections.Generic.IList<ClientProduct> LoadForClient(Client client)
{
if (null != client)
return Load("ClientID = " + client.ID);
else
return null;
}
私は1私は後で
private void LoadProducts(Client client)
{
Products = ClientProduct.LoadForClient(client)
.Select(x => x.Product.Name)
.OrderBy(x => x).ToArray();
}