Yeah. In C# the expressions are lazily evaluated as well so you won't get
an Admin created unless the query returns no result.


Michael M. Minutillo
Indiscriminate Information Sponge
http://codermike.com


On Wed, Mar 28, 2012 at 6:10 PM, Mark Hurd <[email protected]> wrote:

> On 28 March 2012 19:16, Peter Maddin <[email protected]> wrote:
>
>> Great!****
>>
>> Thanks every one for their suggestions****
>>
>> This works well****
>>
>> <snip>
>>
>>        var individual = query.FirstOrDefault();****
>>
>>        if(individual == null) individual = new Admin();****
>>
>>
>>
> All of your samples have this. In VB.NET there is the two-valued If
> statement that can simplify this to
>
>  Dim individual = If(query.FirstOrDefault, New Admin())
>
> I believe the C# equivalent is
>
>  var individual = query.FirstOrDefault()??(new Admin());
>
> --
> Regards,
> Mark Hurd, B.Sc.(Ma.)(Hons.)
>

Reply via email to