WorkItems Get and manually set ids

Topics: CAB & Smart Client Software Factory
Apr 25, 2006 at 6:15 AM
originally posted by: turmelma


I seem to have bumped into a weird issue with the WorkItems.Get method where you pass the ID value of the WorkItem you which to get.

In my code the WorkItem I am looking for has been assigned an ID explicitly by some user code (it overrides the default GUID - my string is composed of an easier-to-read identifier string concatenated with a GUID for unicity.)

Now, when I do the following:
WorkItem myWorkItem = RootWorkItem.WorkItems.Get(myID);

where myID is the exact string I have assigned to the WorkItem's ID property, and the WorkItem was effectively added to the RootWorkItem's child collection via AddNew,
This call returns null.

I have traced the lines of the ManagedObjectCollection.cs to see what was happening and noticed it compares the passed value to the DependencyResolutionKey's ID property, not the WorkItem's ID directly. I'm thinking that those two IDs must have been synchronized when the WorkItem was first created but then by assigning a different ID to it, this breaks down. Hence the null result I get.

My questions:
1- Am I assuming the right thing in my above statement
2- Why is the comparison done on the DepencendyResolutionKey's ID not the Value's ID
3- Is there a way around this (I would really benefit in keeping my custom ID assignment)

Apr 25, 2006 at 7:17 AM
originally posted by: BradWilsonMSFT

The WorkItem.ID property is unrelated to the WorkItem's ID in the DI container.
Apr 25, 2006 at 8:09 AM
originally posted by: turmelma


then I don't understand the purpose of the Get method applied to a collection of WorkItems... can you explain how one could make use of it to search for a specific WorkItem ?
Apr 25, 2006 at 8:39 AM
originally posted by: BradWilsonMSFT

Like all the other facade collections over the Items collection, the WorkItems collection can be used to get an object based on the ID it went into the container with. If you happen to know what ID your WorkItem went into the container with, then you can use that ID. You can control this ID by passing it during your call to WorkItems.CreateNew.

The WorkItem.ID property should more properly be called StateID, since that's really what it affects.
Apr 25, 2006 at 8:51 AM
originally posted by: turmelma

Ah I see. Thanks for the info. I guess I shouldn't use the ID property for some custom purpose then. I'll stay clear of messing with state.

Thanks again,