CodeSmith Community
Your Code. Your Way. Faster!

Stack Overflow Problem...

Latest post 12-20-2007 2:13 AM by swin. 33 replies.
  • 03-27-2007 4:13 PM

    Stack Overflow Problem...

    My schema is simple:

    Models can be part of many Areas.
    Areas can have many Models withing them.

    Models and areas are related m:n via the AreaMembers Table.

    I am trying to load all the data into two collections: ModelEntities, AreaEnties.
    I am using the entitycache.

    My code look like:

    1  private void fillAll()
    {
    3       ModelEntities = getProvider().ModelProvider.GetAll();
    4       loadModelRelatedEntities(ModelEntities);
    5       AreaEntities = getProvider().AreaProvider.GetAll();
    6       loadAreaRelatedEntities(AreaEntities);
    7       modelBindingSource.DataSource = ModelEntities;
    8       areaBindingSource.DataSource = AreaEntities;
    }

    10  private void loadModelRelatedEntities(IMV.ModelListDAL.Entities.TList<Model> ModelEntities)
    11  {
    12      
    foreach (Model m in ModelEntities)
    13       {
    14            m.AreaMemberCollection = getProvider().AreaMemberProvider.GetByModel_id(m.Id);
    15            m.AreaCollection_From_AreaMember =
    16                                    
    getProvider().AreaProvider.GetBymodel_idFromAreaMember(m.Id);
    17       }
    18  }

    19  private void loadAreaRelatedEntities(IMV.ModelListDAL.Entities.TList<Area> AreaEntities)
    20  {
    21      
    foreach (Area a in AreaEntities)
    22       {
    23            a.AreaMemberCollection = getProvider().AreaMemberProvider.GetByArea_id(a.Id);
    24            a.ModelCollection_From_AreaMember =
    25                                    
    getProvider().ModelProvider.GetByarea_idFromAreaMember(a.Id);
    26       }
    27  }

    You may be wondering why I didn't use deepload with the false option for
    recursive fetching... well I was getting a stack overflow exception so since
    deepload had way to much code to wade through I just wrote this by hand.
    Problem is that it also overflows.  Any ideas why?

    • Post Points: 90
  • 03-27-2007 4:26 PM In reply to

    • GRAW
    • Top 25 Contributor
    • Joined on 06-23-2006
    • Posts 157
    • Points 4,560

    Re: Stack Overflow Problem...

    Ornithopter,

    you can get around the DeepLoad() stack overflow by enabling EntityTracking in the configuration file.  Then you won't have to do what u're doing.

    By the way, the Entity caching feature and the EntityTracking feature are not the same thing, even though they're usually triggered by the same setting. 

    "Small is the number of them that see with their own eyes, and feel with their own hearts" Albert Einstein
    • Post Points: 35
  • 03-27-2007 6:06 PM In reply to

    Re: Stack Overflow Problem...

    I have entity tracking and entity caching enabled.

    I still have the problem above.

    • Post Points: 35
  • 03-28-2007 9:02 AM In reply to

    • GRAW
    • Top 25 Contributor
    • Joined on 06-23-2006
    • Posts 157
    • Points 4,560

    Re: Stack Overflow Problem...

    When does this overflow problem occur for you?  When filling the child collections, or when setting the DataSource on the BindingSource?

    If it's caused in your data binding calls, then you're experiencing the same issue I have been dealing with, detailed here:  

    http://community.codesmithtools.com/forums/permalink/23079/23029/ShowThread.aspx#23029

    I got around this problem by changing the template file \Entities\EntityData.cst, at lines 160 and 180, removing the calls to MakeCopyOf() and just assigning a reference to the existing object (parentSource or child collection) to the newly cloned object.  MakeCopyOf() attempts to make a deep copy of the entire object graph which gets it in trouble very easily with self-referential entities.

     

    "Small is the number of them that see with their own eyes, and feel with their own hearts" Albert Einstein
    • Post Points: 65
  • 03-28-2007 9:41 AM In reply to

    • swin
    • Top 10 Contributor
    • Joined on 06-14-2006
    • London, UK
    • Posts 922
    • Points 34,710

    Re: Stack Overflow Problem...

    Reply |Contact |Answer

    Have you guys seen this patch http://community.codesmithtools.com/forums/thread/23364.aspx

    hth

    swin
     

    ------------------------------------------------- Member of the .NetTiers team -------------------------------------------------
    • Post Points: 35
  • 03-28-2007 11:27 AM In reply to

    Re: Stack Overflow Problem...

    Graw,

    Okay so I numbered my lines of code... nope the problem occurs when I try to
    run line 23 for the second object in the Areas collection.  This is really strange
    because why would it work for the first object and not the second?

    • Post Points: 5
  • 03-28-2007 11:28 AM In reply to

    Re: Stack Overflow Problem...

    Swin,

    Is this patch integrated into the current svn version?

    • Post Points: 5
  • 03-28-2007 4:33 PM In reply to

    Re: Stack Overflow Problem...

    Okay, so to answer my own question, the patch IS NOT integrated into the trunk.

    Yes this patch fixes my problem.

    For those (like me this morning) who don't know how to apply the patch, you
    will need to download tortoiseSVN.  Install it.  Then get the latest version of
    netTiers off of version control.  Then download the patch in in above link.

    Move the patch to the ..NetTiers\source\trunk folder.  Right click on the file
    in Windows Explorer, select Apply patch from the Tortoise context menu.
    You will see a floating pane with a list of files that are going to be patched,
    right click on it and select "Patch All"... your files are now updated.  Use
    the updated template to regenerate your DAL.

    • Post Points: 35
  • 04-02-2007 1:59 PM In reply to

    • maqster
    • Top 500 Contributor
    • Joined on 03-23-2007
    • Posts 11
    • Points 325

    Re: Stack Overflow Problem...

    Hi,

    I have downloaded and installed tortoiseSVN, but I don't really understand how to connect to netTeirs source control, I have tried to paste the https://nettiers.svn.sourceforge.net/svnroot/nettiers nettiers in the running Import on TortoiseSVN.

    I have read the instructions at SourceForge:
    This project's SourceForge.net Subversion repository can be checked out through SVN with the following instruction set:
    svn co https://nettiers.svn.sourceforge.net/svnroot/nettiers nettiers

    But I must say I don't really get it, I'm a newbie on SVN and SourceForge, please advise an idiot.

    Best regards
    Maqster

    • Post Points: 35
  • 04-02-2007 2:38 PM In reply to

    • mike123
    • Top 10 Contributor
    • Joined on 02-25-2005
    • Toronto, Ontario
    • Posts 726
    • Points 16,910

    Re: Stack Overflow Problem...

    Maqster,

    Use this path to directly connect to the current trunk https://svn.sourceforge.net/svnroot/nettiers/source/trunk/Source

    1. Right click on the folder that you'll use to download the source into

    2. Choose 'SVN Checkout ...'

    3. Specify https://svn.sourceforge.net/svnroot/nettiers/source/trunk/Source in the 'Url of the repository'

     


    Mike Shatny
    --------------------------------------------------------------
    Member of the .netTiers team http://www.nettiers.com
    --------------------------------------------------------------

    • Post Points: 35
  • 04-02-2007 3:56 PM In reply to

    • maqster
    • Top 500 Contributor
    • Joined on 03-23-2007
    • Posts 11
    • Points 325

    Re: Stack Overflow Problem...

    Mike,

    I've got it :) Thanks

    But I get this error message trying to apply the patch:

    D:\NetTiersSVN\Source\Entities is not a working copy.
    Can't open file D:\NetTiersSVN\Source\Entities\.svn\entries:

    Can't find the path.

    /maqster

     

    • Post Points: 35
  • 04-02-2007 4:32 PM In reply to

    • mike123
    • Top 10 Contributor
    • Joined on 02-25-2005
    • Toronto, Ontario
    • Posts 726
    • Points 16,910

    Re: Stack Overflow Problem...

    Maqster,

    Ah-ha, try then checking out the entire svn source from the following path  https://svn.sourceforge.net/svnroot/nettiers

    alternatively you could edit the patch itself and strip the  the Source/ like following in every occurrence:

    --- Source/Entities/EntityInstanceBase.generated.cst	(revision 528)
    +++ Source/Entities/EntityInstanceBase.generated.cst (working copy)


     

    Mike Shatny
    --------------------------------------------------------------
    Member of the .netTiers team http://www.nettiers.com
    --------------------------------------------------------------

    • Post Points: 35
  • 04-03-2007 1:37 AM In reply to

    • maqster
    • Top 500 Contributor
    • Joined on 03-23-2007
    • Posts 11
    • Points 325

    Re: Stack Overflow Problem...

    Thanx Mike, but now I get another error.

    When trying to patch EntityInstanceBase.generated.cst I get the following:

    There are still unresolved conflicts in line 765!
    You should resolve those conflicts first before saving.
    Do you want to save the file with the conflicts still here?
    If you click YES, then you have to manually resolve the conflicts in another editor!

     What to do?

     /maqster

    • Post Points: 5
  • 04-03-2007 4:12 AM In reply to

    • maqster
    • Top 500 Contributor
    • Joined on 03-23-2007
    • Posts 11
    • Points 325

    Re: Stack Overflow Problem...

    Hi again,

     I merged the file EntityInstanceBase.generated.cst and copied only the changed files in the Entities folder to my templates library.

     But when I try to run the NetTiers.cst file I get the following errors on EntityInstanceBase:

    d:\Mina dokument\CodeSmith\Templates\Rea\Rea_NetTiers2.0.1\Entities\EntityInstanceBase.generated.cst(64,6): error CS0103: The name 'IncludeGeneratedDate' does not exist in the current context
    d:\Mina dokument\CodeSmith\Templates\Rea\Rea_NetTiers2.0.1\Entities\EntityInstanceBase.generated.cst(228,18): warning CS0429: Unreachable expression code detected
    d:\Mina dokument\CodeSmith\Templates\Rea\Rea_NetTiers2.0.1\Entities\EntityInstanceBase.generated.cst(228,43): warning CS0429: Unreachable expression code detected
    d:\Mina dokument\CodeSmith\Templates\Rea\Rea_NetTiers2.0.1\Entities\EntityInstanceBase.generated.cst(232,18): warning CS0429: Unreachable expression code detected
    d:\Mina dokument\CodeSmith\Templates\Rea\Rea_NetTiers2.0.1\Entities\EntityInstanceBase.generated.cst(232,41): warning CS0429: Unreachable expression code detected
    d:\Mina dokument\CodeSmith\Templates\Rea\Rea_NetTiers2.0.1\Entities\EntityInstanceBase.generated.cst(241,15): warning CS0429: Unreachable expression code detected
    d:\Mina dokument\CodeSmith\Templates\Rea\Rea_NetTiers2.0.1\Entities\EntityInstanceBase.generated.cst(342,103): error CS0117: 'MoM.Templates.CommonSqlCode.ReturnFields' does not contain a definition for 'FriendlyName'

     Please advise.

    /Maqster

    • Post Points: 35
  • 04-03-2007 10:22 AM In reply to

    • bgjohnso
    • Top 10 Contributor
    • Joined on 09-15-2005
    • Spokane, WA
    • Posts 764
    • Points 22,530

    Re: Stack Overflow Problem...

    Maqster,

     Why are you copying the file to a new directory?  You are trying to use part of the latest set of templates with the remainder of your old set of templates.  Try running your project using the netTiers.cst that you download from SVN.

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

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