Using:
LLBLGen Pro 2.5 final September 24th 2007
Oracle 10g via ODP.Net
Adapter templates for .Net 2.0 (general)
On .Net Framework 3.5
Hi!
I think i have a genuine bug here...
When transferring an entity over WCF, Its fields DbValue(s) are set to null.
This is causing me serious issues when trying to update a nullable field to null, since the DetermineIfFieldShouldBeSet() in UtiltyClasses, using the DbValue to determine if a change is required.
I've managed to reproduce it with a simple application:
We have an LLBLGen project with one enity for one table:
TestNullable:
ID (number(5)) - PK
NullableNumber (number(5)) - Nullable
I'v put one record there with values (2, 2)
There's a wcf service in one web site application that simply fetches the entity by ID and returns it, and a console client application that uses the wcf. The Enity class is known to both sides, i.e. the WCF client proxy does not create any proxy class for it.
Then we can see that the DB Value is null, though the actual value is 2. Setting the nullable value to null will do nothing (SetValue returns false).
here's the client code that demonstrates the problem:
//We'll get the entity through WCF, so after serialization
ServiceReference1.ServiceClient client = new TestConsole.ServiceReference1.ServiceClient();
TestNullableEntity transferredEntity = client.GetEntity(1);
Console.Write("transferredEntity.NullableNumber Value:");
Console.WriteLine(transferredEntity.NullableNumber);
//Print 2 - correct value
Console.Write("transferredEntity.Fields[\"NullableNumber\".DbValue:");
//Prints Null - should be 2
Console.WriteLine(transferredEntity.Fields["NullableNumber"].DbValue);
//Update the value to null:
transferredEntity.NullableNumber = null;
//Still Prints 2 - value was not set
Console.Write("transferredEntity.NullableNumber Value after setting to null:");
Console.WriteLine(transferredEntity.NullableNumber);
//Update the value to -99:
transferredEntity.NullableNumber = -99;
//Still Prints 2 - value was not set
Console.Write("transferredEntity.NullableNumber Value after setting to -99:");
Console.WriteLine(transferredEntity.NullableNumber);
//Update the value to null again
transferredEntity.NullableNumber = null;
//now prints null - value was set
Console.Write("transferredEntity.NullableNumber Value after setting to null:");
Console.WriteLine(transferredEntity.NullableNumber);
Console.Read();
return;
I've attached to reproduction code. I had to delete some DLLs from the bins, so you have to link them to local version. The projects and solution are Visual studio 2008 ones.
It might be a fixed bug, but haven't seen it in the change log.
If you have any further questions i'll be able to reply only on sunday...
Thanks and have a good weekend,
Amitay Dobo