16,015,072 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by KentBill (Top 5 by date)
KentBill
18-Jan-15 19:54pm
View
I think I found why then exception was thrown. The DataRow object BuyerInfoRow being a property of another class. It was inited in a method(named MethodA) with a DataTable method - NewRow(), and the DataTable object is a local variable of the MethodA, and then the BuyerInfoRow object access by another method(named MehtodB). When MethodA finished running, the DataTable object which the DataRow object belong to was over its life circle and released, in another word, DataRow object lost its DataTable property value and RowState property changed to Detached, after that, in MethodB, while DataRow object was accessed, RowNotInTableException Throw.
KentBill
15-Jan-15 20:45pm
View
And then in the set operation of property BuyerInfo, I query the row(s) by relation and update them?
KentBill
14-Jan-15 23:30pm
View
You mean I should design the "Master - Detail" relationship of the entities to be data relations, instead of class and it’s properties?
KentBill
14-Jan-15 23:26pm
View
Yes, you are right, the BuyerInfo property of Order object will be init when Order object created, I query the buyer information row in the table by buyer ID from order object, and assign it to the BuyerInfo property.
KentBill
13-Jan-15 22:47pm
View
Thank you, Tomas, I created the strong typed DataRow class - BuyerInfoRow in following way.
I created the entity classes of the system as strong typed DataSet. In Visual Studio .NET, I created a Datset.cs file in project, and drop a table(e.g. Order table) from Server Explorer, it creates the classes of Order(OrderDatatable, OrderRow, OrderColumn, OrderTableAdapter....), include OrderDataTable, OrderRow, OrderColumn.... Create the classes of BuyerInfo by same way, and extend then OrderRow class, added a property BuyerInfo it's datatype is BuyerInfoRow, please see the following code.
public partial class DataSet1 {
///
/// Extend the OrderRow class
///
partial class OrderRow
{
#region BuyerInfo of Order
private BuyerInfoRow m_drBuyerInfo;
///
/// BuyerInfo of Order
///
public BuyerInfoRow BuyerInfo
{
get
{
return this.m_drBuyerInfo;
}
set
{
if (value != null)
{
this.m_drBuyerInfo = value;
}
}
}
#endregion
}