This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Привет черти, как там житуха в Новой Зеландии ??!!! Just in case you can't read the above - just read the below ;) Got this exception 'An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll' with stack trace info 'Cannot evaluate expression because the current thread is in a stack overflow state.' See the attached shema picture of a DataBase. I marked by red pencil the reason of the exception. It seams it is a circular reference. As you may see there Dislocation. ServiceArea refer to Dislocation, Dislocation refer to Subdivision, Subdivision refer to ServiceArea. If I break a circular at any point exception disapears. Don't consider me nuts. I realy need that circular it has a special meaning. Subdivision is located somwhere (Dislocation). But it responsible for some particular ServiceArea. Which in the same time is Dislocation :) Hope you will be able to fix the exception to make me happy :) Looking forward to see a nigthly build with the fix. Thanks
|
|
|
Could you clarify whether you are seeing this issue in the designer or at runtime? Also, could you provide us with the .lsmodel file and generated .cs file? I have had a go at reproducing this from the screenshot but no luck, so having your real model would be a great help. Thanks! Finally, just as a caveat, although we will obviously try to fix the stack overflow bug, this may still leave you with a problem with the circular association anyway, as LightSpeed needs to be able to order tables so that it can arrange inserts (parents must always be inserted before children). Looking at your model it appears that you will have a circular chain of foreign keys so LightSpeed will not be able to determine an order for these three tables, in which case you will still get an error even after we have fixed the stack overflow. (I may be misreading your model though.) You may therefore need to tweak your model to avoid the circularity anyway (e.g. by replacing one of the associations with a FK field, and using a manual query to traverse the FK.) |
|
|
Ivan much thanks for a reply. Exception occurs in runtime when tring to perform any query which has assosiation with Dislocation table. The most important thing for me is to be able to perform select quries on DataModel entities and keep all assosiations between them. I mean it is much less important to do inserts. I mean I agree to live with exception on inserts stage (going to use stored procedures for saving), but can't live with such exceptions during select queries. So, I would be much happy if you can resolve circular during selects. I won't post a bug while inserts :) P.S. in the attachment see the model. |
|
|
Unfortunately the checking for circularity is baked pretty deeply into LightSpeed's internal data structures -- it's not easy for us to provide a way to turn it off. As an alternative approach, I would suggest that you break the circularity by removing one of the associations and having the foreign key field just as a normal property. Then, in the partial classes, provide methods/properties to traverse the foreign key. For example, suppose you decided to break the Dislocation.ServiceArea association and replace it with a Dislocation.ServiceAreaId property. Then you could add the following properties in the partial class: partial class Dislocation { partial class ServiceArea { Because these aren't LightSpeed associations, they won't trigger LightSpeed's automatic wiring and therefore won't register as a circular association. Obviously there are some downsides e.g. will query the DB every time they are used, not settable, may not play nicely with entities in the New state (though you may be able to work around this by using FindOne<> instead of First()), doesn't appear in the designer (and hence designer sync issues). But I'm afraid we're not likely to be able to make the core fix you request in the near future, so this is making do with the next best thing -- sorry! |
|