reproduced.
(edit): A bug in the GetScalar code. This error pops up as the usage of the GetScalar method would force you to use the overload with the expression parameter otherwise, but with the new field constructor which accepts an expression, this is no longer necessary.
What happens is that because you don't specify an expression 'null' is specified to the overload which is called to do the actual getscalar. As null is specified, it will be set as the expression to use on the field. Of course, this overwrites the dbfunctioncall.
It should only set the expression on the field in the getscalar if it's not yet set OR if the expression to set is not null. Will fix this in the next build.
You can work around this by using:
[Test]
public void ScalarQueryWithoutTableReferenceTest()
{
ResultsetFields fields = new ResultsetFields(1);
fields[0] = new EntityField2("UpperCaseString", new DbFunctionCall("UPPER", new object[] { "test string" }));
string toConvert = "test string";
string result = string.Empty;
using(DataAccessAdapter adapter = new DataAccessAdapter())
{
result = (string)adapter.GetScalar(new EntityField2("UpperCaseString", null), new DbFunctionCall("UPPER", new object[] { toConvert }), AggregateFunction.None);
}
Assert.AreEqual(toConvert.ToUpperInvariant(), result);
}
instead, so specify the db call as the expression to apply on the field specified.