Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic ItemCollection uniqueness (Read 4707 times)
Tom Keeler
Guest


ItemCollection uniqueness
Apr 11th, 2006 at 3:56pm
Print Post  
Hi,
Can someone please clarify which propery(ies) of a derived Item class define uniqueness in an Item collection?  I have a situation where I am adding a similar Item (exact same Start/End times and Name, but different "Contact" or "Resource" data) but this seems to cause a duplicate key exception in the ItemCollection's underlying dictionary. 

I also notice that my custom Item class (inherited from Appointment) does not get its Id property set for me when I create it then add it to the Schedule.  I think this is the root of the problem actually, but would like to make sure.  I am not overriding the Id property in my inherited class.  Should I override this property and provide my own "unique" Id?  Or am I missing something that is causing the Id not to get set automatically?

If it is not the Id that is causing my error, please define the unique constraint for items.  Let me know if it would be possible to derive our own criteria for uniqueness, since we will often have the same "Name + StartTime" situation but grouped by different "Contact" and/or "Resource" data (thus considered distinct by our business logic).


Thanks for your help,
Tom
  
Back to top
 
IP Logged
 
Tom Keeler
Guest


Re: ItemCollection uniqueness
Reply #1 - Apr 11th, 2006 at 4:57pm
Print Post  
Just to add some more info, I have tried setting the base (Item) Id in my constructor for the custom derived Appointment object to a Guid string, but it seems to always get reset to "0".  None of my items are getting Ids it seems.  I haven't seen this problem with Contacts, as they get Id set when I add them to the calendar.

I am in a Timetable view also if that helps.
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: ItemCollection uniqueness
Reply #2 - Apr 11th, 2006 at 7:43pm
Print Post  
Hi,

Your assumption about the item's uniqueness is correct. Items are considered equal when they have the same Ids (and the same OccurrenceIndex for recurring items). The Id property is initialized once in the Appointment's constructor and as far as my observations go there is no place in the control's code where it is explicitly changed. Can you please provide me with a sample code from your application regarding this issue?

Thank you.

Meppy
  
Back to top
 
IP Logged
 
Tom Keeler
Guest


Re: ItemCollection uniqueness
Reply #3 - Apr 12th, 2006 at 12:26pm
Print Post  

I guess I should have been calling the base constructor.  Poor oversight of my code on my part  Embarrassed

I had assumed the Schedule set the id when it was added, so I didn't even think about the fact I was missing the base() call by accident.

Thanks
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: ItemCollection uniqueness
Reply #4 - Apr 12th, 2006 at 1:07pm
Print Post  
I think though, that the base class' constructor should be invoked automatically from your constructor, even if you don't explicitly call base(). This makes me wonder why the Id property would remain uninitialized.

Never mind, try calling the base constructor explicitly and tell me how it goes. If the problem persists, could you send me your application to inspect it at my site?

Meppy
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint