public async Task SetTimeoutAsync(string id, TimeSpan?timeout)
        {
            using (var db = await dbContextProvider.CreateDbContextAsync())
            {
                var o = await db.FindAsync <StateObjectData>(id);

                if (o == null)
                {
                    db.StateObjects.Add(o = new StateObjectData()
                    {
                        Id = id
                    });
                }

                o.Timeout = timeout;

                await db.SaveChangesAsync();
            }
        }
        public async Task SetFlagAsync(string id, uint?extraFlags)
        {
            using (var db = await dbContextProvider.CreateDbContextAsync())
            {
                var o = await db.FindAsync <StateObjectData>(id);

                if (o == null)
                {
                    db.StateObjects.Add(o = new StateObjectData()
                    {
                        Id = id
                    });
                }

                o.ExtraFlags = extraFlags;

                await db.SaveChangesAsync();
            }
        }
        public async Task SetLockAsync(string id, uint cookie, DateTime time)
        {
            using (var db = await dbContextProvider.CreateDbContextAsync())
            {
                var o = await db.FindAsync <StateObjectData>(id);

                if (o == null)
                {
                    db.StateObjects.Add(o = new StateObjectData()
                    {
                        Id = id
                    });
                }

                o.LockCookie = cookie;
                o.LockTime   = time;

                await db.SaveChangesAsync();
            }
        }
        public async Task SetDataAsync(string id, byte[] data, uint?extraFlags, TimeSpan?timeout)
        {
            using (var db = await dbContextProvider.CreateDbContextAsync())
            {
                var o = await db.FindAsync <StateObjectData>(id);

                if (o == null)
                {
                    db.StateObjects.Add(o = new StateObjectData()
                    {
                        Id = id
                    });
                }

                o.Data       = data;
                o.ExtraFlags = extraFlags;
                o.Timeout    = timeout;
                o.Touched    = DateTime.Now;

                await db.SaveChangesAsync();
            }
        }