views:

51

answers:

1

Suppose I have a function call from EF like:

var result = context.myFunction();

the result type is ObjectResult<int?>. Then I want to use linq to get the single value. How to write the linq?

+1  A: 

Maybe something like this

result.SkipWhile(o => !o.HasValue).Take(1)
Yury Tarabanko
In IntelliSense,only these methods available: Dispose, Equals, GetEnumerator, GetHashCode, GetType, Tostring for type ObjectResult<int?>.
KentZhou
Add using System.Linq;
Yury Tarabanko
By the way if you need just first result then First() or FirstOrDefault() would be enough.
Yury Tarabanko
thank you. it is because of missing using System.Linq;
KentZhou