This website is intended as archive for old content and forums.
Please visit http://opf3.codeplex.com for the project's new website.

General Discussion

FORUM TOPIC

What is Opf3? Why is Opf3? How is Opf3? All these burning questions and issues discussed here.

RSS
Stephen Scott
Posted on the 10/09/07 10:25 AM
UniqueIdentifier field and nulls
Reply Quote
 I have a property of a business object that maps to a unique identifier field in a SqlServer database.
In C# the property uses a Guid as below.

private Guid _rateCodeId;
[Field("RateCodeId", AllowDBNull = true)]
public Guid RateCodeId
{
get { return _rateCodeId; }
set { _rateCodeId = value; }
}

Can you suggest how I might set this field to null as Guid does not accept null. What technique would you advise.

Thanks


Christian Liensberger [Moderator]
Posted on the 10/09/07 2:15 PM
RE: UniqueIdentifier field and nulls
Reply Quote
 Hi!

.NET 2.0 supports nullable types. In C# you only put a ? after the type declaration. Like for example with a guid:

private Guid? _id = null;


These types allow then to be set to null Smile Opf3 detects that and saves a dbnull.

I hope this helps.

Greetings,
Christian

All times are in GMT.