次のテーブルがあります
クライアント テーブルと製品テーブル
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; }
}
クライアントクラス
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();
}