Having Guid field in LINQ SELECT causes invalid cast exception

424 views
Skip to first unread message

Vlad Novgorodov

unread,
Nov 2, 2011, 5:05:24 PM11/2/11
to ravendb
Hi,

I've found a problem in build 472. The first query in the example
below works fine, but the second one causes "InvalidCastException":

var good = _session.Query<TestView>().Select(x => new
{ x.TestField }).ToArray();
var error = _session.Query<TestView>().Select(x =>
x.TestField ).ToArray();

The problem only occurs if type of "TestField" is Guid. Below is the
exception stack trace:

System.InvalidCastException: Invalid cast from 'System.String' to
'System.Guid'.
at System.Convert.DefaultToType(IConvertible value, Type
targetType, IFormatProvider provider)
at System.String.System.IConvertible.ToType(Type type,
IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType,
IFormatProvider provider)
at Raven.Json.Linq.Extensions.Convert[U](RavenJToken token, Boolean
cast)
at Raven.Json.Linq.Extensions.Convert[U](RavenJToken token)
at Raven.Json.Linq.RavenJObject.Value[T](String key)
at
Raven.Client.Document.SessionOperations.QueryOperation.DeserializedResult[T]
(RavenJObject result)
at
Raven.Client.Document.SessionOperations.QueryOperation.Deserialize[T]
(RavenJObject result)
at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1
collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at
Raven.Client.Document.SessionOperations.QueryOperation.Complete[T]()
at Raven.Client.Document.AbstractDocumentQuery`2.GetEnumerator()
at Raven.Client.Linq.RavenQueryInspector`1.GetEnumerator()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
.....

Itamar Syn-Hershko

unread,
Nov 2, 2011, 5:10:32 PM11/2/11
to rav...@googlegroups.com
Can you try this with the latest unstable build please, we did some work on that part this week.

Vlad Novgorodov

unread,
Nov 2, 2011, 5:29:06 PM11/2/11
to ravendb
I will hardly be able to do it. Probably, only with the next stable
build. Hope the problem will have gone.

On Nov 2, 11:10 pm, Itamar Syn-Hershko <ita...@hibernatingrhinos.com>
wrote:
> Can you try this with the latest unstable build please, we did some work on
> that part this week.
>

Itamar Syn-Hershko

unread,
Nov 2, 2011, 5:45:54 PM11/2/11
to rav...@googlegroups.com
No, this actually wasn't fixed. We have a failing test and will fix soon. Thanks for that.

Samina Azad

unread,
Dec 14, 2011, 1:12:06 AM12/14/11
to ravendb
Is this bug fixed yet? I am using build 531.

On Nov 3, 3:45 am, Itamar Syn-Hershko <ita...@hibernatingrhinos.com>
wrote:


> No, this actually wasn't fixed. We have a failing test and will fix soon.
> Thanks for that.
>

Oren Eini (Ayende Rahien)

unread,
Dec 14, 2011, 5:04:22 AM12/14/11
to rav...@googlegroups.com
It is fixed after 531
Reply all
Reply to author
Forward
0 new messages