public static IEnumerable <GraphData> GroupBy(this IQueryable <GraphData> graphData, int interval = 0, DateTime?firstDay = null)
        {
            if (interval <= 0)
            {
                return(graphData);
            }

            DateTime realFirstDay = firstDay ?? graphData.First().Timestamp;
            var      q            = from d in graphData
                                    let groupNumber = VinesenseContext.DateDiff(d.Timestamp, firstDay).Value / interval
                                                      let groupNumberInteger = DbFunctions.Truncate((double)groupNumber, 0)
                                                                               group d by(int) groupNumberInteger.Value into g
                                                                               select new
            {
                GroupNumber = g.Key,
                Value       = g.Average((d) => d.Value)
            };

            return(from v in q.AsEnumerable()
                   select new GraphData
            {
                Timestamp = realFirstDay + TimeSpan.FromDays(interval * v.GroupNumber),
                Value = v.Value
            });
        }
        public DbContext CreateContext()
        {
            var context = new VinesenseContext();

            // context.Database.Log = (log) => Debug.WriteLine(log);
            return(context);
        }