Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Bizobj updates unchanged rows.
Message
From
20/09/2004 14:47:14
 
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
00939368
Message ID:
00944139
Views:
13
Kevin,
Where is the "Known Issues" page?

Terry Carroll



>
>>I have a Parent-Child form very similar to the CustomerOrdersForm. When I insert, update, or delete any row of the child business object all rows are updated on SQL-Server. So if I have 20 child rows and I delete 3 of them I get 57 updates in the database. If I add 3 I get 63 updates. I know this is happening because the update triggers are firing.
>
>I looked into this and as it turns out, if you have a business object's ForeignParentKeyField property set, the business object's PopulateKeyField() method is inadvertently setting the foreign parent key field of all rows in the DataTable. That's because the code in PopulateKeyField() is checking the following:
>
>
row[keyField] != keyValue
>
>This code was intended to check if the values were different, but since both the row column and the keyValue parameter are of type object, the equality test is checking if they are referencing the same object rather than testing if they have the same value. The check should have been:
>
>
!keyValue.Equals(row[keyField])
>
>For now, you can get around this problem by overriding your ABusinessObject's PopulateKeyField() method as shown here:
>
>
protected override void PopulateKeyField(string keyField, object keyValue,
>	string tableName)
>{
>	System.Data.DataTable dt = this.GetCurrentDataSet().Tables[tableName];
>	foreach (System.Data.DataRow row in dt.Rows)
>	{
>		if (row[keyField] == System.DBNull.Value || !keyValue.Equals(row[keyField]))
>		{
>			row[keyField] = keyValue;
>		}
>	}
>}
>
>I'll add this to our "Known Issues" page and give you credit for finding this in the next version of the What's New Guide.
>
>Regards,
Previous
Reply
Map
View

Click here to load this message in the networking platform