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
|
Hi Guys, We have a setup where we have a double class table inheritance. When using this setup, we get an IndexOutOfRangeException. The setup is as follows. We have an AgreementBase entity. We've set this up as an abstract class. Not sure this makes any difference though. From this entity we derive TemplateAgreement and Agreement (abstract). We derive both classes through class table inheritance using a field AgreementBaseType. From Agreement we then derive two more classes CustomerAgreement en ResellerAgreement, again through Class table inheritance, on a field AgreementType. When I now fill in the data for (for instance) a CustomerAgreement and query the data (I use LinqPad with your driver, which is an excellent combination to test LS models), I get this IndexOutOfRangeException. When digging a bit deeper, it seems to look for a field AgreementBase.AgreementType, which obviously does not exist. When I check the SQL that gets generated, this looks fine and when I run the SQL directly against the database, I get the appropriate results. The complete error message I get is: p.p1 {margin: 5.0px 0.0px 5.0px 0.0px; font: 12.0px 'Times New Roman'; color: #1738f5} p.p2 {margin: 5.0px 0.0px 5.0px 0.0px; font: 12.0px 'Times New Roman'} p.p3 {margin: 5.0px 0.0px 5.0px 0.0px; text-align: center; font: 12.0px 'Times New Roman'} p.p4 {margin: 5.0px 0.0px 5.0px 0.0px; font: 12.0px 'Times New Roman'; min-height: 15.0px} span.s1 {text-decoration: underline} span.s2 {color: #000000} table.t1 {border-collapse: collapse} td.td1 {border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #cbcbcb #cbcbcb #cbcbcb #cbcbcb; padding: 0.0px 5.0px 0.0px 5.0px}
I've used version 3.1 and 3.11, both with this same result. Any suggestions? If you want, I can attach a small sample (with just AgreementBase (abstract), Agreement (abstract) and CustomerAgreement) that demonstrates the issue.
I hope you guys can help, as this is now blocking one of my co-workers.
Kind regards,
Robert Echten
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
Hi Robert, Could you give this a quick try with the latest nightly please? I believe we have fixed a related bug though it's possible this is something distinct. If it does still happen with the latest nightly, let us know and we'll take a look (and that sample you offered would definitely help -- thanks!). |
|
|
Hi Ivan, I've tried this with my sample project (with the very original name TestModel) but unfortunately this made no difference. I've attached a zip file which contains the sample project and a small database backup for the sample, containing a minimal data set. I hope this helps. Robert |
|
|
Just in case it wasn't clear: I used LinqPad with the Lightspeed driver and then simply tried to retrieve CustomerAgreements. This should result in the error. The SQL tab should show you the SQL that can be, successfully, run against the database, which should return 1 row. Robert |
|
|
Are you saying that the problem only occurs in LinqPad, and that the same query works correctly in your own applications? |
|
|
Unfortunately no. A co-worker noticed the issue while developing on the business logic for our system. I just mentioned the Linqpad thing, as the test project does not contain any specific logic to get the data. I used Linqpad to connect to the model and then query it, but using it in an application would give you the same result (at least it does in ours).
|
|
|
At least part of the problem is that you are using multiple discriminators -- AgreementBaseType and AgreementType. You should be using only one discriminator across the entire class table inheritance hierarchy. You should remove the Agreement.AgreementType property, and change the discriminator settings on CustomerAgreement to use AgreementBaseType (with a suitable value). See http://www.mindscape.co.nz/forums/Post.aspx?ThreadID=3566&PostID=12161 for related discussion (refers back to http://www.mindscape.co.nz/forums/Post.aspx?ThreadID=3566&PostID=12160). If you still see problems after making this change, can you post the updated model *and* the troublesome LINQ query please? Thanks! |
|
|
Hi Ivan,
I gave this a try and it indeed fixes the issue. In a way it makes sense to only have a single discriminator for all levels, although intuitively, I expected a separate discriminator for each level. Silly me for trying to think for myself ;-) Thanks a lot for the quick resolution, as always. Kind regards, Robert |
|