Version : 4.3.5 build 6242
Query:
var query = Query.All<MyEntity>()
.Select(e => new
{
MyEntity = e,
Year = (int?)e.Date.Value.Year,
Status = e.Infos.OfType<SuccessInfo>().Any() ? Status.Success : (e.Infos.OfType<ErrorInfo>().Any() ? Status.Error : Status.Unknown)
})
.Select(o => new object[] { o.MyEntity.Id, o.Year, o.Status });
Exception:
System.InvalidCastException was unhandled
Message=Specified cast is not valid.
Source=Xtensive.Core
StackTrace:
at Xtensive.Core.Tuples.Tuple.GetValueOrDefaultInternal[T](Boolean isNullable, Int32 fieldIndex)
at Xtensive.Core.Tuples.Tuple.GetValueOrDefault[T](Int32 fieldIndex)
at lambda_method(Closure , Object[] , Tuple , ItemMaterializationContext )
at Xtensive.Core.DelegateBindExtensions.<>c__DisplayClassa`4.<Bind>b__9(T2 arg2, T3 arg3)
at Xtensive.Storage.Linq.Materialization.MaterializationHelper.<>c__DisplayClass4`1.<Materialize>b__3(Tuple tuple)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at Xtensive.Core.EnumerableExtensions.<Batch>d__20`1.MoveNext()
at Xtensive.Core.EnumerableExtensions.<ApplyBeforeAndAfter>d__28`1.MoveNext()
at Xtensive.Storage.TransactionalExtensions.<ToTransactional>d__0`1.MoveNext()
at System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
Test project :
http://olorin.dinauz.org/temp/TestMaterializationBug.zip
The really strange thing is that the same query works if I change the order of selected columns...
asked
Oct 05 '10 at 12:40
olorin
358●87●87●92
PS: is there a function to upload files? that would be practical for those who don't have a webserver handy.
Unfortunately, there is no such function (we depend on OSQA in this case). But sending us a sample via e-mail is ok.
Concerning the issue: definitely a bug. We got a very similar report from one of our own teams today, so likely, we introduced some new issue related to materialization of anonymous type in one of the latest updates.