Exemplo n.º 1
0
        public async Task <Adjective> ReadRandomAsync()
        {
            int count = await _session.Select <Adjective>().CountAll().From().ScalarAsync <int>();

            int       offset = HelperService.GetRandomNumber(0, count);
            Adjective adj    = await _session.SelectAllFrom <Adjective>().OrderBy(x => x.Value).Limit(offset, 1).FirstOrDefaultAsync();

            return(adj);
        }
Exemplo n.º 2
0
        public async Task <Noun> ReadRandomAsync()
        {
            try
            {
                int count = await _session.Select <Noun>().CountAll().From().ScalarAsync <int>();

                int  offset = HelperService.GetRandomNumber(0, count);
                Noun noun   = await _session.SelectAllFrom <Noun>().OrderBy(x => x.Value).Limit(offset, 1).FirstOrDefaultAsync();

                return(noun);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.InnerException.ToString());
            }
        }