Bug 56088 - LinqToSql FirstOrDefault with include
Summary: LinqToSql FirstOrDefault with include
Status: NEEDINFO
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Data (show other bugs)
Version: 5.0.0 (2017-02)
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-05-08 01:54 UTC by amenegatti
Modified: 2017-09-29 14:50 UTC (History)
2 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description amenegatti 2017-05-08 01:54:22 UTC
The following code:

var user = context.Users.Include(t => t.Applications).FirstOrDefault(u => u.Id == id);

Throws the following exception:

{System.IndexOutOfRangeException: Index was outside the bounds of the array.
  at Mono.Data.Tds.Protocol.TdsDataRow.get_Item (System.Int32 index) [0x0000e] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/TdsDataRow.cs:84 
  at System.Data.SqlClient.SqlDataReader.GetValue (System.Int32 i) [0x0006b] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/System.Data/System.Data.SqlClient/SqlDataReader.cs:1254 
  at System.Data.SqlClient.SqlDataReader.IsDBNull (System.Int32 i) [0x00000] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/System.Data/System.Data.SqlClient/SqlDataReader.cs:1303 
  at System.Data.Entity.Core.Common.Internal.Materialization.Shaper+ErrorHandlingValueReader`1[T].GetValue (System.Data.Common.DbDataReader reader, System.Int32 ordinal) [0x00000] in <000f54522ad145bf987b3043022f9799>:0 
  at System.Data.Entity.Core.Common.Internal.Materialization.Shaper.GetPropertyValueWithErrorHandling[TProperty] (System.Int32 ordinal, System.String propertyName, System.String typeName) [0x00007] in <000f54522ad145bf987b3043022f9799>:0 
  at (wrapper dynamic-method) System.Object:lambda_method (System.Runtime.CompilerServices.Closure,System.Data.Entity.Core.Common.Internal.Materialization.Shaper)
  at System.Data.Entity.Core.Common.Internal.Materialization.Shaper.HandleEntityAppendOnly[TEntity] (System.Func`2[T,TResult] constructEntityDelegate, System.Data.Entity.Core.EntityKey entityKey, System.Data.Entity.Core.Metadata.Edm.EntitySet entitySet) [0x000c6] in <000f54522ad145bf987b3043022f9799>:0 
  at (wrapper dynamic-method) System.Object:lambda_method (System.Runtime.CompilerServices.Closure,System.Data.Entity.Core.Common.Internal.Materialization.Shaper)
  at System.Data.Entity.Core.Common.Internal.Materialization.Coordinator`1[T].ReadNextElement (System.Data.Entity.Core.Common.Internal.Materialization.Shaper shaper) [0x00060] in <000f54522ad145bf987b3043022f9799>:0 
  at System.Data.Entity.Core.Common.Internal.Materialization.Shaper`1+RowNestedResultEnumerator[T].MaterializeRow () [0x00063] in <000f54522ad145bf987b3043022f9799>:0 
  at System.Data.Entity.Core.Common.Internal.Materialization.Shaper`1+RowNestedResultEnumerator[T].MoveNext () [0x0002d] in <000f54522ad145bf987b3043022f9799>:0 
  at System.Data.Entity.Core.Common.Internal.Materialization.Shaper`1+ObjectQueryNestedEnumerator[T].TryReadToNextElement () [0x00013] in <000f54522ad145bf987b3043022f9799>:0 
  at System.Data.Entity.Core.Common.Internal.Materialization.Shaper`1+ObjectQueryNestedEnumerator[T].MoveNext () [0x0001b] in <000f54522ad145bf987b3043022f9799>:0 
  at System.Data.Entity.Internal.LazyEnumerator`1[T].MoveNext () [0x0002b] in <000f54522ad145bf987b3043022f9799>:0 
  at System.Linq.Enumerable.TryGetFirst[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Boolean& found) [0x00045] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/external/corefx/src/System.Linq/src/System/Linq/First.cs:75 
  at System.Linq.Enumerable.First[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x00000] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/external/corefx/src/System.Linq/src/System/Linq/First.cs:14 
  at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.<GetElementFunction>b__0[TResult] (System.Collections.Generic.IEnumerable`1[T] sequence) [0x00000] in <000f54522ad145bf987b3043022f9799>:0 
  at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.ExecuteSingle[TResult] (System.Collections.Generic.IEnumerable`1[T] query, System.Linq.Expressions.Expression queryRoot) [0x00006] in <000f54522ad145bf987b3043022f9799>:0 

The same code works ok on Windows.
Comment 1 Marek Safar 2017-09-29 14:50:20 UTC
Thank you for your report!

I’m unable to reproduce this issue locally using the information you provided. In order to investigate the issue further can you please attach a reproduction project and steps to reproduce this issue? For help on writing a bug report, please see our guide on this topic:

https://bugzilla.xamarin.com/page.cgi?id=bug-writing.html

Some of your next steps would be:

1. Including a sample project or steps to reproduce this problem
2. Your Version Information
3. Your expected results and actual results

Thank you!

Note You need to log in before you can comment on or make changes to this bug.