web如果要表示一对多的对象结构,我们可以采用如下的方式(表明了一个入库单的结构,这个入库单包含了入库单头和相关明细):
public class Form : PersistenceCapable
{
private EntityData form;
private FormDetail formDetail;
#region 构造函数
public Form() : this(true)
{}
public Form(bool AutoInit)
{
form=EntityPrototypeManager.GetEmptyEntity("Form");
if(AutoInit)
form.NewRecord("Form");
}
public Form(EntityData entity)
{
form=entity;
}
#endregion
#region 属性
public string FormID
{
get{return form["FormID","Form"].ToString();}
set{form["FormID","Form"]=value;}
}
public DateTime FormTime
{
get{return form.GetDateTime("FormTime","Form");}
set{form["FormTime","Form"]=value;}
}
public FormDetail FormDetail
{
get
{
if(formDetail==null)
{
formDetail=new FormDetail(form);
}
return formDetail;
}
}
#endregion
#region PersistenceCapable 成员
public int ObjectCount
{
get
{
return form.EntityCount;
}
}
public EntityData EntityData
{
get
{
return form;
}
set
{
form=value;
}
}
public bool Next()
{
return form.Next("Form");
}
public void First()
{
form.First("Form");
}
public void AddNew()
{
form.NewRecord("Form");
}
#endregion
}
public class FormDetail : PersistenceCapable
{
private EntityData form;
#region 构造函数
public FormDetail() : this(true)
{}
public FormDetail(bool AutoInit)
{
form=EntityPrototypeManager.GetEmptyEntity("Form");
if(AutoInit)
form.NewRecord("FormDetail");
}
public FormDetail(EntityData entity)
{
form=entity;
}
#endregion
#region 属性
public string FormDetailID
{
get{return form["FormDetailID","FormDetail"].ToString();}
set{form["FormDetailID","FormDetail"]=value;}
}
public string FormID
{
get{return form["FormID","FormDetail"].ToString();}
set{form["FormID","FormDetail"]=value;}
}
public string ProductID
{
get{return form["ProductID","FormDetail"].ToString();}
set{form["ProductID","FormDetail"]=value;}
}
public decimal InCount
{
get{return form.GetDecimal("InCount","FormDetail");}
set{form["InCount","FormDetail"]=value;}
}
#endregion
#region PersistenceCapable 成员
public int ObjectCount
{
get
{
return form.Tables["FormDetail"].Rows.Count;
}
}
public EntityData EntityData
{
get
{
return form;
}
set
{
form=value;
}
}
public bool Next()
{
return form.Next("FormDetail");
}
public void First()
{
form.First("FormDetail");
}
public void AddNew()
{
form.NewRecord("FormDetail");
}
#endregion
}
Websharp使用说明(3)
80酷酷网 80kuku.com