Yitzchok / subsonicproject

Automatically exported from code.google.com/p/subsonicproject
0 stars 0 forks source link

ArgumentException in Recordbase.CopyTo(DataTable dataTable) #93

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Error Message:
Cannot set column "ColumnName" to be null. Please use DBNull instead.

What steps will reproduce the problem?
Call ToDataTable() of <YourObject>Collection (AbstractList).
If a value ist null, the new datarow should get DB

What is the expected output? What do you see instead?
Copy null value to new row without throwing ArgumentException.

What version of the product are you using? On what operating system?
r522

Fix:
RecordBase.cs:724
should be

newRow[setting.ColumnName] = setting.CurrentValue == null ? DBNull.Value :
setting.CurrentValue;

Original issue reported on code.google.com by isep...@gmail.com on 27 May 2009 at 9:13

GoogleCodeExporter commented 9 years ago
more compact:
newRow[setting.ColumnName] = setting.CurrentValue ?? DBNull.Value;

Original comment by isep...@gmail.com on 27 May 2009 at 9:27

GoogleCodeExporter commented 9 years ago
@isepsie: Didn't know the ?? syntax, but you never stop learning, right?
thx.

Original comment by j.steinblock@gmail.com on 29 May 2009 at 8:36