CodeSmith Community
Your Code. Your Way. Faster!

What the ... ???

Latest post 05-22-2008 7:13 PM by blake05. 4 replies.
  • 04-16-2008 9:07 PM

    • kolsson
    • Not Ranked
    • Joined on 04-17-2008
    • Posts 3
    • Points 105

    What the ... ???

    I'm using Nettiers 2.2 and very happy with it. Lately we tracked down a problem that occurred when we did a MarkForDelete() on all children, followed by the parents and executed with DeepSave(). We run into a problem in that it generated an exception that turned out to be a foreign key contraint violation that only happened if the TList contained more than 300 entities. When searching through the code, I discovered the following in one of the templates (EntityProviderCoreClass.generated.cst):

     

            /// Adds the specified entity property to the collection of properties.
            /// </summary>
            /// <param name="entity"></param>
            /// <param name="key"></param>
            public void AddRun( Object entity, string key )
            {
                if (entity != null && !string.IsNullOrEmpty(key))
                {
                    string lkey;
                    if (entity is IEntity)
                        lkey = ((IEntity)entity).EntityTrackingKey + key;
                    else
                        lkey = entity.GetHashCode().ToString()+ key;

                    DeepSessionInnerList.Add(lkey, entity);
                }
               
                if (DeepSessionInnerList.Count > 300)
                    CancelSession = true;

            }

     

    Can anyone shed any light as to why the number 300 is hard coded into the template and preventing a DeepSave() of more than 300 child entities? Intentional or a bug?

     

    • Post Points: 65
  • 04-17-2008 10:12 PM In reply to

    • SuperJeffe
    • Top 25 Contributor
    • Joined on 05-05-2006
    • Tulsa, Ok
    • Posts 484
    • Points 11,980

    Re: What the ... ???

    Well, we ran accross this and this is an attempt to make sure that they don't get into an infinite loop.  If you had circular foreign keys in tables, they try and make sure this won't happen.  I do agree that at Runtime, this check should not occur.  They should put the check at Generation time and not a run-time.  If there are circular references, they should not be generated.

    here is another conversations about this:

    http://community.codesmithtools.com/forums/p/6005/23340.aspx#23340

    I really do believe this should be changed but I would find a work around if I were you or manually take it out of your template and see if it works.

    jeff

    ----------------------------------------------------------------------
     Member of the .NetTiers team | Visit http://www.nettiers.com
    ----------------------------------------------------------------------

    • Post Points: 35
  • 04-17-2008 11:21 PM In reply to

    • kolsson
    • Not Ranked
    • Joined on 04-17-2008
    • Posts 3
    • Points 105

    Re: What the ... ???

    Thanks for the reply. I think this is a bug. We have a simple parent child relationship and it failes when we do a DeepSave from a  TList with 500 parent entities. I'll add some comments on the issue in the thread you linked to.

     

    Cheers! 

    • Post Points: 35
  • 04-18-2008 8:39 AM In reply to

    • SuperJeffe
    • Top 25 Contributor
    • Joined on 05-05-2006
    • Tulsa, Ok
    • Posts 484
    • Points 11,980

    Re: What the ... ???

    Reply |Contact |Answer

    I would say it is a bug as well.  I think we got around this issue in our business logic layer and just did our own loop and saved the children.  One advantage of the way we use nettiers, we just use the Entities and data layers so we have our own business layer to do what we need to do.

    jeff

    ----------------------------------------------------------------------
     Member of the .NetTiers team | Visit http://www.nettiers.com
    ----------------------------------------------------------------------

    • Post Points: 5
  • 05-22-2008 7:13 PM In reply to

    • blake05
    • Top 10 Contributor
    • Joined on 04-03-2008
    • Wisconsin
    • Posts 685
    • Points 13,380

    Re: What the ... ???

     Hello,

    We have added this to our to-do list. You can check the status of this here

    Thanks

    -Blake

    Blake Niemyjski

    CodeSmith Tools, LLC. Software Development Engineer

    Blog: http://windowscoding.com/blogs/blake/

    ----------------------------------------------------------------------
     Member of the .NetTiers team | Visit http://www.nettiers.com
    ----------------------------------------------------------------------

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