Beispiel #1
0
        GetPortfolio()
        {
            using (var table = connection.Select(@"
SELECT Stocks.name, total(Flows.shares) as shares
from Stocks left join Flows
on Flows.stock == Stocks.id
group by Stocks.id
order by name"))
            {
                foreach (DataRow record in table.Rows)
                {
                    yield return((string)record[0], (double)record[1]);
                }
            }

            Dirty = false;
        }
        GetPortfolio()
        {
            var ans = new List <(string StockName, double TotalShares)>();

            using (var query = Connection.Select(
                       @"SELECT Stocks.name, total(Flows.shares) as shares
from Stocks left join Flows
on Flows.stock = Stocks.id
group by Stocks.id
order by name"))
            {
                while (query.Read())
                {
                    ans.Add((query.GetString(), query.GetDouble()));
                }
            }
            IsPortfolioChanged = false;
            return(ans);
        }