I'm sorry it's pretty simple but I just couldn't get my head around it. I've checked the internet and search for answers but I couldn't find a specific one for my question or I just don't know how to look for it. I'm fairly new in Xamarin Forms and I'm stuck with this problem with using SQLite; I am able to get all the values from a column and display it to a ListView. Now, I want to display the sum of the items in the ListView but I couldn't get it at all. The database has two entries so far with 20 and 5 respectively to the column I want to get the sum of. Here's what I tried so far:
var getSum = conn.Query<tblAccount>("Select sum(ac_income) from tblAccount where ac_date between ? and ? and ac_incomeOrExpense =?", dpIncomeFrom.Date, dpIncomeTo.Date, "income").ToList();
//1st i tried - return a long string of column description
var getSum = conn.Table<tblAccount>().Where(u => u.ac_incomeOrExpense =="income").Sum(a => a.ac_income);
//this shows something of the same as the below codes but still it's not the correct result I was looking for
var getSum = conn.Table<tblAccount>().Sum(a => a.ac_income);
//for some reason this gives a result of 87 - don't know where it's getting that
So as obvious as it is, I'm still wrapping my head around how to call a query properly with Xamarin forms. If anyone could help or at least an example of how to call a query and displaying it properly, I'll be grateful. Thanks.