public override async Task <int> LoadLastCheckpointAsync(string projectorIdentifier)
        {
            TCheckpointInfo checkpointInfo = null;

            try
            {
                checkpointInfo = connection.Get <TCheckpointInfo>(projectorIdentifier);
            }
            catch
            {
                try
                {
                    if (!connection.TableExists("CheckpointInfos"))
                    {
                        connection.CreateTable(typeof(CheckpointInfo));
                        checkpointInfo = connection.Get <TCheckpointInfo>(projectorIdentifier);
                    }
                }
                catch
                {
                }
                // TODO: error handling
            }

            if (checkpointInfo == null)
            {
                return(-1);
            }

            return(checkpointInfo.CheckpointNumber);
        }
예제 #2
0
 public Task <T> GetAsync <T>(Expression <Func <T, bool> > predicate)
     where T : new()
 {
     if (predicate == null)
     {
         throw new ArgumentNullException("predicate");
     }
     return(Task.Factory.StartNew(() =>
     {
         SQLiteConnectionWithLock conn = GetConnection();
         using (conn.Lock())
         {
             return conn.Get(predicate);
         }
     }, CancellationToken.None, _taskCreationOptions, _taskScheduler ?? TaskScheduler.Default));
 }
예제 #3
0
 public Task <T> GetAsync <T>(object pk)
     where T : new()
 {
     if (pk == null)
     {
         throw new ArgumentNullException("pk");
     }
     return(Task.Factory.StartNew(() =>
     {
         SQLiteConnectionWithLock conn = GetConnection();
         using (conn.Lock())
         {
             return conn.Get <T>(pk);
         }
     }, CancellationToken.None, _taskCreationOptions, _taskScheduler ?? TaskScheduler.Default));
 }
예제 #4
0
 public Task <T> GetAsync <T>(Expression <Func <T, bool> > predicate)
     where T : new()
 {
     if (predicate == null)
     {
         throw new ArgumentNullException("predicate");
     }
     return(_taskFactory.StartNew(() =>
     {
         SQLiteConnectionWithLock conn = GetConnection();
         using (conn.Lock())
         {
             return conn.Get(predicate);
         }
     }));
 }
예제 #5
0
 public Task <T> GetAsync <T>(object pk)
     where T : new()
 {
     if (pk == null)
     {
         throw new ArgumentNullException("pk");
     }
     return(_taskFactory.StartNew(() =>
     {
         SQLiteConnectionWithLock conn = GetConnection();
         using (conn.Lock())
         {
             return conn.Get <T>(pk);
         }
     }));
 }
예제 #6
0
        public Recipe FindRecipe(int id)
        {
            if (_isDisposed)
            {
                throw new ObjectDisposedException(nameof(RecipePersistenceService));
            }
            if (id <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(id));
            }
            RecipeRow row = null;

            using (_connection.Lock())
            {
                row = _connection.Get <RecipeRow>(x => x.Id == id);
            }
            return(row?.ToRecipe(_referenceBook));
        }