Print Page | Close Window

Verification for FK Key property

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3216
Printed Date: 21-Oct-2025 at 6:25pm


Topic: Verification for FK Key property
Posted By: katit
Subject: Verification for FK Key property
Date Posted: 13-Jan-2012 at 1:35pm
I have Customer object and it's got TimeZoneKey property which is FK
 
When I bind TimeZone on customer screen - it looks like this:
 

<

ComboBox ItemsSource="{Binding TimeZones}" SelectedValue="{Binding CurrentItem.TimeZoneKey, Mode=TwoWay}" Grid.Column="1" Grid.Row="5" Margin="1" SelectedValuePath="TimeZoneKey" DisplayMemberPath="DisplayName" TabIndex="5">

</ComboBox>

 

Where I have issue is that verifier doesn't work. RequiredValueValidator is there, but problem is that if TimeZone not selected from dropdown - Key stays "0", not null and it's fine by verifier.
 
Just looking for best way to handle such scenario.
 
1. Default time zone to something?
2. Add another verifier and check to make sure Key>0 ?
3. Somehow stop Key default to 0?



Replies:
Posted By: DenisK
Date Posted: 17-Jan-2012 at 4:54pm
Hi katit,

I'd say that this depends on your business context. If the integer 0 will never be allowed as an id, then option 2 is okay. If 0 is a valid id number, then I'd implement a default negative value.

Another option is to implement your own null entity. Please see below links for more info.

http://drc.ideablade.com/xwiki/bin/view/Documentation/null-entity - http://drc.ideablade.com/xwiki/bin/view/Documentation/null-entity
http://drc.ideablade.com/xwiki/bin/view/Documentation/model-nullentity - http://drc.ideablade.com/xwiki/bin/view/Documentation/model-nullentity



Print Page | Close Window