Exemple #1
0
 public Task <List <T> > ToListAsync()
 {
     return(Task.Factory.StartNew(() => {
         using (((SQLiteConnectionWithLock)_innerQuery.Connection).Lock()) {
             return _innerQuery.ToList();
         }
     }));
 }
        public Task <List <T> > ToListAsync()
        {
            return(Task.Factory.StartNew(() => {
                using (((SQLiteConnectionWithLock)_innerQuery.Connection).Lock()) {
                    List <T> result = null;

                    int busy = 0;
                    do
                    {
                        try
                        {
                            result = _innerQuery.ToList();
                            busy = _maximumNumberOfAttemptsIfBusy;
                        }
                        catch (SQLiteException e)
                        {
                            if (busy >= _maximumNumberOfAttemptsIfBusy)
                            {
                                throw;
                            }
                            if ((e.Message == "Busy") || (e.Message == "database is locked"))
                            {
                                Thread.Sleep(10 * busy);
                                busy++;
                            }
                            else
                            {
                                throw;
                            }
                        }
                    } while (busy < _maximumNumberOfAttemptsIfBusy);
                    return result;
                }
            }));
        }
Exemple #3
0
        public T FirstOrDefault()
        {
            TableQuery <T> source = Take(1);

            return(source.ToList().FirstOrDefault());
        }