Bug 666 - DataColumn Expressions and Column order
Summary: DataColumn Expressions and Column order
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Data ()
Version: 2.10.x
Hardware: Macintosh Mac OS
: High major
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2011-09-07 13:07 UTC by Dominique NORMAND
Modified: 2011-09-13 08:18 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Dominique NORMAND 2011-09-07 13:07:24 UTC
A DataColumn expression cannot reference columns that are defined after (higher ordinal #) the column the expression is assigned to.
We can create all the column and define expression afterward, but then the DataTable.Clone fails crashes.

I think the _compiledExpression should be evaluated only if needed. Either when adding the first row or when accessing the data of that column.

Step to Recreate the defect:

Case 1:
-------

System.Data.DataTable table1 = new System.Data.DataTable("Table1") ;

System.Data.DataColumn c1 = table1.Columns.Add("c1", typeof(string), "'hello ' + c2") ; /* Causes Exception */
System.Data.DataColumn c2 = table1.Columns.Add("c2") ;

Case 2:
-------

System.Data.DataTable table1 = new System.Data.DataTable("Table1") ;

System.Data.DataColumn c1 = table1.Columns.Add("c1") ;
System.Data.DataColumn c2 = table1.Columns.Add("c2") ;

c1.Expression = "'hello ' + c2";

System.Data.DataTable t2 = table1.Clone(); /* Causes Exception */
Comment 1 Rolf Bjarne Kvinge [MSFT] 2011-09-13 08:18:01 UTC
Case 1 doesn't work on windows (it throws an EvaluateException), so our behaviour there is correct.

Case 2 is fixed in 3646906. It will probably reach the next MonoTouch beta.