cast error on relationship RRS feed

  • Question

  • Hey all,

    When doing a submitchanges it seems  there is no update fired. Checking de database confirms it.

    I was trying to update 1 object, and not the associations.

    The stacktrace is:

       at System.Data.Linq.ChangeTracker.StandardChangeTracker.IsFastTracked(Object obj)
       at System.Data.Linq.ChangeTracker.StandardChangeTracker.GetTrackedObject(Object obj)
       at System.Data.Linq.ChangeProcessor.GetOtherItem(MetaAssociation assoc, Object instance)
       at System.Data.Linq.ChangeProcessor.BuildEdgeMaps()
       at System.Data.Linq.ChangeProcessor.SubmitChanges(ConflictMode failureMode)
       at System.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode)
       at System.Data.Linq.DataContext.SubmitChanges()
       at DAL.BaseRepository`2.VoerUitOpDatabase(T entiteit, String mode, Boolean recursief) in C:\Documents and Settings\kscherpenhuijzen\My Documents\Visual Studio 2008\Projects\ConsoleApplication12\DAL\BaseRepository.cs:line 105

    When i try to do:

    ChangeSet set = context.GetChangeSet();

    it is getting me:

    Unable to cast object of type 'System.Data.Linq.EntitySet`1[Programma.PatientAan
    melding]' to type 'Programma.PatientAanmelding'.

    in Patient i have a value declared as:

            private EntitySet<PatientAanmelding> _patientAanmeldingen;
            [Association(Storage = "_patientAanmeldingen", IsForeignKey=true, OtherKey="PatientId")]   //on the other end PatientId is a FK
            public EntitySet<PatientAanmelding> PatientAanmeldingen
                get { return this._patientAanmeldingen; }
                set { this._patientAanmeldingen.Assign(value); }

    the constructor of Patient:

            public patient()
                this._patientAanmeldingen = new EntitySet<PatientAanmelding>();

    Am i missing something here?



    Wednesday, April 7, 2010 11:19 AM

All replies

  • Hello,

    Thanks for your post!

    I'm not sure which version of Entity Framework did you use, however, please take a look at this thread in connect site, please vote there if you encountered the same issue.

    Thanks a lot!

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback, please tell us.
    Welcome to the All-In-One Code Framework!
    Monday, April 12, 2010 8:30 AM