private static string MongoDBFortunes(HttpListenerRequest request, HttpListenerResponse response)
        {
            Benchmarks.AspNet.Models.MongoDB db = new Benchmarks.AspNet.Models.MongoDB("MongoDB");

            List <Fortune> fortunes = db.Fortunes.FindAll().ToList();

            fortunes.Add(new Fortune {
                ID = 0, Message = "Additional fortune added at request time."
            });
            fortunes.Sort();

            response.ContentType = "text/html";
            var template = new Fortunes {
                Model = fortunes
            };

            return(template.TransformText());
        }
        private static string Fortunes(HttpListenerRequest request, HttpListenerResponse response)
        {
            List <Fortune> fortunes = new List <Fortune>();

            using (DbConnection connection = CreateConnection(request))
            {
                connection.Open();

                using (DbCommand command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM Fortune";

                    using (DbDataReader reader = command.ExecuteReader(CommandBehavior.SequentialAccess))
                    {
                        while (reader.Read())
                        {
                            fortunes.Add(new Fortune
                            {
                                ID      = reader.GetInt32(0),
                                Message = reader.GetString(1)
                            });
                        }
                    }
                }
            }

            fortunes.Add(new Fortune {
                ID = 0, Message = "Additional fortune added at request time."
            });
            fortunes.Sort();

            response.ContentType = "text/html";
            var template = new Fortunes {
                Model = fortunes
            };

            return(template.TransformText());
        }
Beispiel #3
0
        private static string Fortunes(HttpListenerRequest request, HttpListenerResponse response)
        {
            List<Fortune> fortunes = new List<Fortune>();

            using (DbConnection connection = CreateConnection(request))
            {
                connection.Open();

                using (DbCommand command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM Fortune";

                    using (DbDataReader reader = command.ExecuteReader(CommandBehavior.SequentialAccess))
                    {
                        while (reader.Read())
                        {
                            fortunes.Add(new Fortune
                            {
                                ID = reader.GetInt32(0),
                                Message = reader.GetString(1)
                            });
                        }
                    }
                }
            }

            fortunes.Add(new Fortune { ID = 0, Message = "Additional fortune added at request time." });
            fortunes.Sort();

            response.ContentType = "text/html";
            var template = new Fortunes { Model = fortunes };
            return template.TransformText();
        }
Beispiel #4
0
        private static string MongoDBFortunes(HttpListenerRequest request, HttpListenerResponse response)
        {
            Benchmarks.AspNet.Models.MongoDB db = new Benchmarks.AspNet.Models.MongoDB("MongoDB");

            List<Fortune> fortunes = db.Fortunes.FindAll().ToList();

            fortunes.Add(new Fortune { ID = 0, Message = "Additional fortune added at request time." });
            fortunes.Sort();

            response.ContentType = "text/html";
            var template = new Fortunes { Model = fortunes };
            return template.TransformText();
        }