See this code:

MyEntity e = Query.All<myentity>().First();

var arr = e.OtherEntities.ToArray(); //OtherEntities is EntitySet<t> property; say we have 100 items in this collection

foreach(var item in arr) //the array is of length 100, but only first 32 items are non-null, others are null Console.Write(item.Text); //this enumerates to 32 items, then you get NullReferenceExeception

a workaround is to use e.OtherEntities.Where(i=>true).ToArray() .. then it retuns all 100 non-null items in the array

David

This thread was imported from our support forum. The original discussion may contain more detailed answer. Original topic by david_csharp.

asked Apr 11 '10 at 16:17

Editor's gravatar image

Editor
46154156157

Definitely a bug. We'll try to fix it ASAP on Monday.

(Apr 11 '10 at 16:17) Alex Yakunin Alex%20Yakunin's gravatar image

One Answer:

The bug was fixed today - it looks like someone of us occasionally removed an important part of logic during EntitySetBase refactoring. Now it's there again.

Nightly build containing the fix will be available in the morning.

answered Apr 20 '10 at 20:18

Alex%20Yakunin's gravatar image

Alex Yakunin
29714412

Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA