Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. LINQ
  4. IndexOutOfRangeException on DataContext.SubmitChanges

IndexOutOfRangeException on DataContext.SubmitChanges

Scheduled Pinned Locked Moved LINQ
databasehelpquestion
5 Posts 2 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rei Miyasaka
    wrote on last edited by
    #1

    Has anyone else had this problem? I make a new object, InsertOnSubmit it, call SubmitChanges, and it crashes. The exception is totally unhelpful. The table is really quite straightforward; the DataContext.Log indicates no SQL commands being generated. Thanks in advance, Rei

    R J 2 Replies Last reply
    0
    • R Rei Miyasaka

      Has anyone else had this problem? I make a new object, InsertOnSubmit it, call SubmitChanges, and it crashes. The exception is totally unhelpful. The table is really quite straightforward; the DataContext.Log indicates no SQL commands being generated. Thanks in advance, Rei

      R Offline
      R Offline
      Rei Miyasaka
      wrote on last edited by
      #2

      As it turns out, one of the other tables that the table references doesn't have its property set to null by default (or something), so I have to explicitly set it to null before I submit if I'm not assigning it. Definitely a bug. Edit: never mind, it's still happening.

      modified on Wednesday, July 30, 2008 11:17 PM

      1 Reply Last reply
      0
      • R Rei Miyasaka

        Has anyone else had this problem? I make a new object, InsertOnSubmit it, call SubmitChanges, and it crashes. The exception is totally unhelpful. The table is really quite straightforward; the DataContext.Log indicates no SQL commands being generated. Thanks in advance, Rei

        J Offline
        J Offline
        Judah Gabriel Himango
        wrote on last edited by
        #3

        Rei, I don't think you've given us enough info to go off of. Stack trace? Table schema? Relevant code? etc.

        R 2 Replies Last reply
        0
        • J Judah Gabriel Himango

          Rei, I don't think you've given us enough info to go off of. Stack trace? Table schema? Relevant code? etc.

          R Offline
          R Offline
          Rei Miyasaka
          wrote on last edited by
          #4

          Sorry about that. I wrote more details on a thread on the MSDN Forums[^]. If I didn't null the Contact property when I inserted a new Email, it would cause an IndexOutOfRangeException when I called SubmitChanges(). Now, for some bizarre reason, I don't need to null the property when I insert, but instead, it causes an IndexOutOfRangeException exception when I submit an update, and a NullReferenceException when I try to set email.Contact = null. And this is the stack trace I get:

          at System.Data.Linq.SqlClient.SqlProvider.AssignParameters(DbCommand cmd, ReadOnlyCollection`1 parms, Object[] userArguments, Object lastResult)
          at System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, Object[] parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object lastResult)
          at System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries)
          at System.Data.Linq.SqlClient.SqlProvider.CompiledQuery.Execute(IProvider provider, Object[] arguments)
          at System.Data.Linq.CommonDataServices.DeferredSourceFactory`1.ExecuteKeyQuery(Object[] keyValues)
          at System.Data.Linq.CommonDataServices.DeferredSourceFactory`1.Execute(Object instance)
          at System.Data.Linq.CommonDataServices.DeferredSourceFactory`1.DeferredSource.GetEnumerator()
          at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source)
          at System.Data.Linq.EntityRef`1.get_Entity()
          at Aoi.Email.set_Contact(Contact value) in C:\Users\rei\Documents\Visual Studio 2008\Projects\AoiData\AoiDataClasses.designer.cs:line 4565

          And this is the stack trace from the IndexOutOfRangeException I get when I try to SubmitChanges() without setting Contact to null first:

          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.ChangeProce

          1 Reply Last reply
          0
          • J Judah Gabriel Himango

            Rei, I don't think you've given us enough info to go off of. Stack trace? Table schema? Relevant code? etc.

            R Offline
            R Offline
            Rei Miyasaka
            wrote on last edited by
            #5

            I think it didn't like me changing the names of some properties in the Contact class. I did change it through the designer though, so I have no idea why it's complaining. Well that was a waste of a day and a half. Thanks, Rei

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups