请教如何设计,主-子表结构的业务逻辑层(简单设计讨论!谢!)
请教如何设计,主-子表结构的业务逻辑层
如:主表StockNote(NoteId,CreateDate)
子表StockNoteItem(NoteId,NoteItemId,ProductId,Amount
)
业务逻辑类如下:
---------------------------
#region 入库单实体。
public class StockNote
{
public StockNote()
{}
private string _NoteId;
public string NoteId
{
get{return this._NoteId;}
set{this._NoteId=value;}
}
private string _CreateDate;
public string CreateDate
{
get{return this._CreateDate;}
set{this._CreateDate=value;}
}
public void Add()
{
/*执行insert into stocknote (_NoteId,_CreateDate)*/
}
public void delete()
{
/*执行delete stocknote where (_NoteId)*/
}
}
#endregion
---------------------------
#region 入库单子表实体。
public class StockNoteItem
{
public StockNoteItem()
{}
private string _NoteId;
public string NoteId
{
get{return this._NoteId;}
set{this._NoteId=value;}
}
private string _NoteItemId;
public string NoteItemId
{
get{return this._NoteItemId;}
set{this._NoteItemId=value;}
}
private string _ProductId;
public string ProductId
{
get{return this._ProductId;}
set{this._ProductId=value;}
}
private int _Amount;
public int Amount
{
get{return this._Amount;}
set{this._Amount=value;}
}
public void Add()
{
/*执行insert into stockNoteItem
(_NoteId,_NoteItemId,_ProductId,_Amount)*/
}
public void delete()
{
/*执行delete stockNoteItem where
(_NoteId,_NoteItemId)*/
}
}
#endregion
---------------------------
--
因为主-子表是 多对一的 所以这样简单的类设计
不能满足要求,请问各位常用的业务逻辑 应该如何写
谢谢
我最不喜欢的就是 主表用类,子表用DataTable
这样不是面向对象的。
我要简单面向对象的。
欢迎各位讨论,发表意见哈,谢谢!!