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
|
Basically the problem lays in a table that has a reference to itself. Let's call it "Foo" -- given a (Guid) key of FooId, there is a nullable field called ParentFooId that has a foreign key to FooId, although the db foreign key has no cascade action. I've set up a One-to-Many-Association to represent this relationship, with properties set to their defaults except IsNullable and IsDependent is set to true (RemovalBehavior remains set to 'SetNull', although this has no effect). Here's the exception that occurs: Mindscape.LightSpeed.LightSpeedException: The field ParentFooId on type [Foo] at Mindscape.LightSpeed.LightSpeedException.?(String , Object[] ) (IUnitOfWork unitOfWork, Type returnType) at Mindscape.LightSpeed.Linq.LinqQueryProvider.System.Linq.IQueryProvider.Execute[S](Expression expression)
In the Working version this exists: [DependentAttribute(ValidatePresence=false)] But in the 'new' non-working version this has been removed, and instead the designer places the attributes as follows: [DependentAttribute(ValidatePresence=false)] [Column("ParentFooId")]
Any ideas? Is this a bug or something I'm doing? UPDATE: with the last nightly build, I've discovered I'm now getting a stack overflow doing an update of this table. Due to application logic I: a) create the object (and save it as an insert) with ParentFoo to null Could 'c' be the root of both problems, in that I'm doing a self-reference in the event that there is no parent? Does Lightspeed require that hierarchical relationships eventually terminate in a null, and not a self-reference? Thanks! |
|
|
An update: I did manage to figure out a work-around. I removed the association (the ParentFoo object property) and now I just manually work with the field directly (ParentFooId). However, for future reference, is there a design issue with Lightspeed where hierarchical relationships must never have parentid == childid to reflect an item with no parent (and instead forces parentid == null)? Thanks! |
|
|
That is correct. An item with parent id = child id would mean an item which is its own parent. To indicate an item with no parent, use a null parent id. (Which is why associations to self are required to be nullable, otherwise the parent hierarchy could never bottom out.) The additional occurrence of DependentAttribute is correct and is the result of a designer fix. |
|