Ah! I'd not noticed, but I use .FirstOrDefault() on the end, which
will either return a blank one (value of 0) or the first one in the
list :)

But if there are no results, you will still get an object back.

On Wed, May 23, 2012 at 1:27 PM, Guido Van Hoecke <[email protected]> wrote:
> Hi Nic,
>
> Your code led me to the solution for my problem.
>
> On 23 May 2012 13:48, Nic Wise <[email protected]> wrote:
>> Very odd. Incase I messed up, here's the _exact_ code I use
>>
>> private class DoubleObj
>> {
>>     public double AmountSum { get; set; }
>> }
>>
>> try
>> {
>>    var inc = conn.Query<DoubleObj>("select sum(Amount) as
>>              AmountSum from \"Transaction\" where
>>              Direction = ? and TransactionDate
>>              between ? and ?",
>>        (int)TransactionDirection.Income,
>>        taxSettings.StartDate,
>>        taxSettings.EndDate).FirstOrDefault();
>>    income += inc.AmountSum;
>> } catch (Exception ex) {
>>     Util.LogException(ex);
>>     income  += 0;
>> }
>
> Note: Could it be that 'income += inc.AmountSum;'
> should really be 'income += inc[0].AmountSum;'?
>
> I did not have the ' as ' part in my sql statement. So there was no way
> of mapping the result set to the List<class> variable. And - obviously -
> the name of the returned value better match the public variable in the
> <class>, and it is not really adviseable to use keywords like 'Count'
> as name for said public variable ;P
>
> Thanks for your help, and have a nice day.
>
> With kind regards,
>
>
>
> Guido
>
> --
> Every little picofarad has a nanohenry all its own.
>                -- Don Vonada
>
> http://vanhoecke.org ... and go2 places!



-- 
Nic Wise
t.  +44 7788 592 806 | @fastchicken | http://www.linkedin.com/in/nicwise
b. http://www.fastchicken.co.nz/

Earnest: Self-employed? Track your business expenses and income.
http://earnestapp.com
Nearest Bus: find when the next bus is coming to your stop. http://goo.gl/Vcz1p
mobileAgent (for FreeAgent): get your accounts in your pocket.
http://goo.gl/IuBU
Trip Wallet: Keep track of your budget on the go: http://goo.gl/ePhKa
London Bike App: Find the nearest Boris Bike, and get riding! http://goo.gl/Icp2
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to