CodeSmith Community
Your Code. Your Way. Faster!

DeepSave bug

Latest post 05-04-2007 10:18 AM by millerwa. 2 replies.
  • 02-14-2007 4:34 PM

    • JJmartin
    • Top 25 Contributor
    • Joined on 05-22-2006
    • Phoenix, AZ
    • Posts 164
    • Points 3,275

    DeepSave bug

    Found this by tracing through a unit test.

    In order to duplicated you need a table structure similar to this: (this very simplified to my layout and the names have been changed to protect the innocent)

    MetaEvent table
    Meta-EventId
    StartEventId
    EndEventId

    Event table
    EventId
    MetaEventId

    Meta Event table combines events and links back to a start event and and end event.  It could also include other events. 
    The EventTable has an Id of what MetaEvent it belongs to.  Each Event may or may not be the StartEvent or the EndEvent.

    you end up with an Event entity that has properties similar to

    MetaEventCollectionGetByStartEventId
    and
    MetaEventCollectionGetByEndEventId

    That was the setup - here is the bug...

    as The Event entity goes through the DeepSave, it creates a Dictionary of Delegates called deepHandles

    then it goes through each of the collection properties (such as the ones listed above) and adds the DeepSave method as the delegate with the MetaEvent.

    Heres where the error happens.  Since those two properties are the same type and could potentially have the Same object in them, the DeepHandles throws an error saying that the item has already been added.

     To clarify.. i have a Event that is referenced as the StartEvent and the EndEvent for a single MetaEvent, which is what is causing the error.

    -Jeff Martin C# MCSD
    • Post Points: 5
  • 02-14-2007 5:59 PM In reply to

    • JJmartin
    • Top 25 Contributor
    • Joined on 05-22-2006
    • Phoenix, AZ
    • Posts 164
    • Points 3,275

    It appears to me that this is probably more serious than the uncommon set up as above and would affect any table that links to another table in two separate fields.

    The main problem is that the delegate is used as the key to the dictionary.  So I fixed this by using a list rather than a dictionary.  The patch is attached.

     

    -Jeff Martin C# MCSD
    • Post Points: 35
  • 05-04-2007 10:18 AM In reply to

    • millerwa
    • Top 500 Contributor
    • Joined on 05-03-2007
    • Posts 18
    • Points 465

    Re: DeepSave bug

    Is this in the current release of nettiers or do I still have to apply the patch... I am having this same sort of issue, basically I have a person table, an attributes table and a personattributes table (PersonID,AttributeID) when I try and add an attribute to the person I get the above mentioned error...

     Thanks

     

    • Post Points: 5
Page 1 of 1 (3 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems