我正在使用.NET 2.0。我有两个对象,一个是PhoneService,另一个是ChartOfAccount。这与之间的关系很多。C中的多对多关系对象#
public class PhoneService
{
private List<ChartAccount> chartAccounts
private ChartAccount chartAccount
public Int64 ID
{
get { return id; }
set { id = value; }
}
public bool Add()
{ ... }
public bool Update()
{ ... }
}
public class ChartAccount
{
public Int64 ID
{
get { return id; }
set { id = value; }
}
public bool Add()
{ ... }
public bool Update()
{ ... }
public bool Allocate()
{
// this will save data for the bridge table only
}
}
现在我的问题,是有可能,当你这样做:
PhoneService service = new PhoneService();
service.ChartAccounts[0].ID = 5
service.ChartAccounts[1].ID = 10
由于ChartAccounts是一个集合,我怎么学尝试把分配(),所以变成这样: 服务.ChartAccounts.Allocate()
我能想到的是将Allocate()方法放在Service类中。有任何想法吗?
谢谢
我宁愿根据具体情况制作一个或另一个。 – dcpartners 2009-10-16 05:50:28