Hi all,
I'm developing a Order Manage System. I designed the entities as strong typed dataset, in other words, a object in then system a business object (e.g. Order, Trade or Payment) is a datarow(a strong typed datarow).
For example, a Order class(inherit DataRow) have a property - BuyerInfo(inherit DataRow). When I init a Order object and it's property BuyerInfo successfully, and get then property values of the BuyerInfo object, a RowNotInTableException threw. show the following message.
"
This row has been removed from a table and does not have any data. BeginEdit() will allow creation of new data in this row."
Anyone know why? Datarow could NOT be a property datatype of a class? thanks.
these another tips here, when I change then member of then Order what saved then BuyerInfo object to a Datatable from Datarow, then exception disappeared! see following code:
Begfore Changing.
#region BuyerInfo of Trade
private BuyerInfoRow m_drBuyerInfo;
public BuyerInfoRow BuyerInfo
{
get
{
return this.m_drBuyerInfo;
}
set
{
if (value != null)
{
this.m_drBuyerInfo = value;
this.buyer_info_id = value.tbbi_gID;
}
}
}
#endregion
After Changing:
#region BuyerInfo of Trade
private BuyerInfo_tbbiDataTable m_dtBuyerInfo;
public BuyerInfoRow BuyerInfo
{
get
{
if ((this.m_dtBuyerInfo == null) || (this.m_dtBuyerInfo.Rows == null) || (this.m_dtBuyerInfo.Count <= 0))
{
return null;
}
else
{
return this.m_dtBuyerInfo[0];
}
}
set
{
if (value != null)
{
if ((this.m_dtBuyerInfo != null) && (this.m_dtBuyerInfo.Rows != null) && (this.m_dtBuyerInfo.Count > 0))
{
this.m_dtBuyerInfo.Clear();
}
if (this.m_dtBuyerInfo == null)
{
this.m_dtBuyerInfo = new BuyerInfo_tbbiDataTable();
}
this.m_dtBuyerInfo.ImportRow(value);
this.buyer_info_id = value.tbbi_gID;
}
}
}
#endregion