IndexOutOfRangeException on DataContext.SubmitChanges
-
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
-
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
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
-
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
Rei, I don't think you've given us enough info to go off of. Stack trace? Table schema? Relevant code? etc.
-
Rei, I don't think you've given us enough info to go off of. Stack trace? Table schema? Relevant code? etc.
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 4565And 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 -
Rei, I don't think you've given us enough info to go off of. Stack trace? Table schema? Relevant code? etc.
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