/// </summary>
public bool IsNull (DataColumn column, DataRowVersion version)
{
+ // use the expresion if there is one
+ if (column.Expression != String.Empty) {
+ // FIXME: how does this handle 'version'?
+ // TODO: Can we avoid the Eval each time by using the cached value?
+ object o = column.CompiledExpression.Eval (this);
+ return o == null && o == DBNull.Value;
+ }
+
return column.DataContainer.IsNull (IndexFromVersion (version));
}
#endregion
}
+ [Test]
+ public void IsNull_BeforeGetValue ()
+ {
+ DataTable table = new DataTable ();
+
+ // add the row, with the value in the column
+ DataColumn staticColumn = table.Columns.Add ("static", typeof(string), null); // static
+ DataRow row = table.Rows.Add ("the value");
+ Assert.IsFalse (row.IsNull ("static"), "static null check failed");
+ Assert.AreEqual ("the value", row ["static"], "static value check failed");
+
+ // add the first derived column
+ DataColumn firstColumn = table.Columns.Add ("first", typeof(string), "static"); // first -> static
+ Assert.IsFalse (row.IsNull ("first"), "first level null check failed");
+ Assert.AreEqual ("the value", row ["first"], "first level value check failed");
+
+ // add the second level of related
+ DataColumn secondColumn = table.Columns.Add ("second", typeof(string), "first"); // second -> first -> static
+ Assert.IsFalse (row.IsNull ("second"), "second level null check failed");
+ Assert.AreEqual ("the value", row ["second"], "second level value check failed");
+ }
+
[Test] public void Item()
{
// init table with columns