Navigation Property ChangeSet Inheritance

Oct 6, 2014 at 1:17 PM
Edited Oct 6, 2014 at 1:22 PM
I've run into this problem in the past, and somehow I fixed it, but I made the mistake of not taking note what I did to bypass this issue. It might have suddenly gone away without my meaning to, and I didn't think about it anymore, but now it's come back with a vengeance...

Whenever I attempt to add entries (delete works fine) from the database via the datacontext, I get an error on line 291 in ChangeSetExtensions.cs:
 if (changeSetEntity != null && !navigationProperty.Contains(changeSetEntity))
The error occurs at the evaluation of "!navigationProperty.Contains". For some reason it tells me that because I'm trying to add a derived type, and my navigation property is of base type, I've got an ArgumentException. Here's the error:
An unhandled exception of type 'System.ArgumentException' occurred in NTier.Common.Domain.dll

Additional information: Argument expected to be of type Aerospace.CCADE.Common.Domain.Model.AerosPACE.MissionLeg and got type Aerospace.CCADE.Common.Domain.Model.AerosPACE.Landing.
MissionLeg is the base type, and Landing one of the derived types. Is there anything I can do? I've thought of casting it as the base type in the changeSetEntity, but I'm not sure if that would cause problems later...

Thanks for your help!
Oct 6, 2014 at 1:33 PM
So I noticed that while debugging, my ChangeSetExtensions.cs had a few less lines than in the main project. So I decided to rebuild my NTier.Common.Domain.dll to see if that did anything, and it fixed the problem O_o.

If anyone has any comments on possible explanations why this error occured, or had similar problems, please let me know. This may be the second time that I've unwittingly avoided this problem, but I'd like a better understanding of why it's cropping up in the first place.

Oct 12, 2014 at 9:01 PM
There's an error concerning inheritance which has only recently been fixed and released with version 1.5
A possible explanation of why the issue got resolved and then came back again was that you might have been switching between pre-releases and stable build and/or your own build of the framework.
Nov 6, 2014 at 1:22 AM
So, I was stupid and tried to change builds and overwrote my old one with version 1.5. I think the error is still there. Here's how I fixed it:

Line 324 of TrackableCollection.cs:
        if (obj.GetType() != typeof(T))
I changed it to:
        if (!(obj is T))

A crude solution perhaps, but it gets the job done. I downloaded from the Source page. Maybe this was fixed and I just don't see it on Codeplex? Can you please point me to the right download site if this is the case?
Nov 6, 2014 at 7:24 AM
Edited Nov 6, 2014 at 8:22 PM
Thank you very much for your input.
Your suggestion makes sense to me. I'm going the change the code in the framework.

UPDATE: change commited in change set 4c32ad250f8b