Note that there are some explanatory texts on larger screens.

plurals
  1. POInvalidOperationException Occurred in Linq orderby clause
    primarykey
    data
    text
    <p>Here is the linq statement I am using:</p> <pre><code>var sortedList = (from p in OriginalList where p.NValue != null orderby Math.Abs(p.NValue.Value) descending select p); </code></pre> <p>OriginalList is a list of Transaction objects with more than 10 thousand elements. NValue is nullable property of Transaction. Every time OriginalList is updated, the statement will be executed. </p> <p>I have found that from time to time, this statement could throw the following exception: System.InvalidOperationException: Nullable object must have a value.</p> <p>I tried to do unit testing and fed it with an OriginalList with only one Transaction. This Transaction has null NValue. It won't trigger this exception.</p> <p>Anyone has idea what is going on here? Thanks a lot.</p> <p>We are using Linq to SQL. Here is the stack trace:</p> <p>2011-10-05 16:14:06,826 [SRV101 DC\Admin] [59] ERROR Utils.AProxy`1 - AProxy [TProxy] error during load</p> <pre><code>System.InvalidOperationException: Nullable object must have a value. at CServer.TLoader.b__2(Trasaction p) in c:\...\TLoader.cs:line 61 at System.Linq.EnumerableSorter`2.ComputeKeys(TElement[] elements, Int32 count) at System.Linq.EnumerableSorter`1.Sort(TElement[] elements, Int32 count) at System.Linq.OrderedEnumerable`1.d__0.MoveNext() at CServer.TLoader.GetMultipliers(IEnumerable`1 OriginalList) in c:\...\TLoader.cs:line 64 at CServer.TProxy.OnLoad() in c:\...\TProxy.cs:line 29 at Utils.AProxy`1.Load() in c:\...\AProxy.cs:line 252 </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload