日期:2013-07-12  浏览次数:20429 次

如果要表示一对多的对象结构,我们可以采用如下的方式(表明了一个入库单的结构,这个入库单包含了入库单头和相关明细):

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["Form