public object Get(DbRequest request)
        {
            OrmLiteConfig.DialectProvider = MySqlDialectProvider.Instance;

            var random = new Random();
            using (var db = MYSQL_CONNECTION_STRING.OpenDbConnection())
            {
                if (request.queries == 0)
                    return GetRandomWorld(db, random);
                else
                {
                    var worldCount = request.queries > 500 ? 500 : request.queries;
                    worldCount = worldCount < 1 ? 1 : worldCount;

                    // NOTE: Experiment with running the DB requests in parallel, on both Mono and Windows CLRs.
                    var worlds = new World[worldCount];

                    for (int i = 0; i < worldCount; ++i)
                    {
                        worlds[i] = GetRandomWorld(db, random);
                    }
                    return worlds;
                }
            }
        }
Пример #2
0
        public object Get(DbRequest request)
        {
            OrmLiteConfig.DialectProvider = MySqlDialectProvider.Instance;

            var random = new Random();

            using (var db = MYSQL_CONNECTION_STRING.OpenDbConnection())
            {
                if (request.queries == 0)
                {
                    return(GetRandomWorld(db, random));
                }
                else
                {
                    var worldCount = request.queries > 500 ? 500 : request.queries;
                    worldCount = worldCount < 1 ? 1 : worldCount;

                    // NOTE: Experiment with running the DB requests in parallel, on both Mono and Windows CLRs.
                    var worlds = new World[worldCount];

                    for (int i = 0; i < worldCount; ++i)
                    {
                        worlds[i] = GetRandomWorld(db, random);
                    }
                    return(worlds);
                }
            }
        }