public IEnumerable <Event> GetEventDetails(DateTime?start, DateTime?end)
        {
            List <Event> ae = new List <Event>();

            try
            {
                using (var context = new ETLChatContext())
                {
                    string sql = String.Format("spTransactionSelect @startDate = '{0}',@endDate = '{1}'", "1/1/1975 12:00:00 AM", "1/1/2025 12:00:00 AM");
                    ae = context.Events.FromSqlRaw(sql).ToList();
                }
            }
            catch (Exception exc) { }

            return(ae);
        }
        public IEnumerable <AggregatedEvents> GetAggregatedEvents(int minutes)
        {
            List <AggregatedEvents> ae = new List <AggregatedEvents>();

            //using (var context = new ETLChatContext())
            //{
            //  string sql = String.Format("SELECT [StartDate],[EndDate],[Enter],[Leave],[Comment],[HiFive] FROM [Event_Agg_15]");
            //  int r = context.Database.ExecuteSqlRaw< AggregatedEvents>(sql);
            //}
            //return ae;

            //as the above is not supported on Core 2.0 EF 3.1 we are going back 10 years to ADO.NET SqlCommand :) goodbye POCO friendly interfaces

            try
            {
                using (var context = new ETLChatContext())
                {
                    using (var command = context.Database.GetDbConnection().CreateCommand())
                    {
                        if (command.Connection.State != ConnectionState.Open)
                        {
                            command.Connection.Open();
                        }
                        command.CommandText = "Exec spAggregateSelect @minutes = " + minutes;
                        DbDataReader reader = command.ExecuteReader();
                        while (reader.Read())
                        {
                            ae.Add(new AggregatedEvents()
                            {
                                StartDate = Convert.ToDateTime(reader["StartDate"]),
                                EndDate   = Convert.ToDateTime(reader["EndDate"]),
                                Enter     = Convert.ToInt32(reader["Enter"]),
                                Leave     = Convert.ToInt32(reader["Leave"]),
                                Comment   = Convert.ToInt32(reader["Comment"]),
                                HiFive    = Convert.ToInt32(reader["HiFive"])
                            });
                        }
                    }
                }
            }
            catch (Exception exc) { }

            return(ae);
        }