none
LINQ Update query failing:IndexOutOfRangeException RRS feed

  • Question

  • I am running into a problem trying to update a table in LINQ.  I have three tables

    DicomStudyTable->DICOMSeriesTable->DICOMImageTable

    study is a parent to series, series is a parent to image.  I get the below error when i try and execute submit change to update the image table

    DataClasses1DataContext d = new DataClasses1DataContext("Connection  string");
    DICOMImageTable tempImage = d.DICOMImageTables.SingleOrDefault(p => p.SS_DICOMImage_ID == 4);
     tempImage.ImageType = "test";
     d.SubmitChanges();

    This fails on submit change.  And ideas?  Thanks!!



    System.IndexOutOfRangeException was unhandled
      Message="Index was outside the bounds of the array."
      Source="System.Data.Linq"
      StackTrace:
           at System.Data.Linq.IdentityManager.StandardIdentityManager.MultiKeyManager`3.TryCreateKeyFromValues(Object[] values, MultiKey`2& k)
           at System.Data.Linq.IdentityManager.StandardIdentityManager.IdentityCache`2.Find(Object[] keyValues)
           at System.Data.Linq.IdentityManager.StandardIdentityManager.Find(MetaType type, Object[] keyValues)
           at System.Data.Linq.CommonDataServices.GetCachedObject(MetaType type, Object[] keyValues)
           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 ConsoleApplication4.Program.Main(String[] args) in C:\Users\karliso\Documents\Visual Studio 2008\Projects\ConsoleApplication4\ConsoleApplication4\Program.cs:line 50
           at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
           at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()
      InnerException:

    Wednesday, November 26, 2008 4:27 PM

Answers

  • This unfortunately happens when you have a foreign key referring to something that is not the primary key that L2S was told about.  It is a bug where L2S thinks it can use these foreign key values as keys into the identity map for a given entity but they really don't match.
    Wednesday, November 26, 2008 4:50 PM
    Moderator

All replies

  • This unfortunately happens when you have a foreign key referring to something that is not the primary key that L2S was told about.  It is a bug where L2S thinks it can use these foreign key values as keys into the identity map for a given entity but they really don't match.
    Wednesday, November 26, 2008 4:50 PM
    Moderator
  • Is there away around this?
    Saturday, November 29, 2008 9:24 PM
  • Unfortunately not at this time although it is being fixed for 4.0.

    [)amien
    Tuesday, December 2, 2008 9:05 AM
    Moderator
  • Unfortunately not at this time although it is being fixed for 4.0.
    I figured out, that this is even fixed in the Windows7 edition of .net Framework 3.5 SP1. Yes, there are two different editions of the same framework :-(
    Tuesday, August 24, 2010 9:14 AM
  • I found the solution for the error, which exists (to my best knowledge) only on the xp-version of the .net-framework.

    http://social.msdn.microsoft.com/Forums/en/linqtosql/thread/04007c6d-1473-4e27-bb0e-8968073571be?prof=required&ppud=4

    Tuesday, August 24, 2010 10:21 AM
  • FWitteler

    The link in your post keeps returning me to this page. Can you point me to the solution you found? Or should i just tell my customer to upgrade from XP right away?

     


    Yr Obdt Srvnt
    Tuesday, November 16, 2010 12:31 PM