Exemple #1
0
        protected override Transaction AddEntity(RedisContext entityContext, Transaction entity)
        {
            string transactionObj = entity.ToJson();

            entityContext.GetDb().HashSet(entity.AccountNo, entity.Id, transactionObj);

            return(entity);
        }
Exemple #2
0
        protected override Customer GetEntity(RedisContext entityContext, string id)
        {
            var db = entityContext.GetDb();

            string obj = db.StringGet(id);

            var res = JsonConvert.DeserializeObject <Customer>(obj);

            return(res);
        }
Exemple #3
0
        protected override IEnumerable <Transaction> GetEntities(RedisContext entityContext, string k)
        {
            var trans = entityContext.GetDb().HashGetAll(k);

            List <Transaction> lt = new List <Transaction>();

            foreach (var item in trans)
            {
                lt.Add(JsonConvert.DeserializeObject <Transaction>(item.Value));
            }

            return(lt);
        }
Exemple #4
0
        protected override CustomerAccount GetEntity(RedisContext entityContext, string id)
        {
            var d = entityContext.GetDb();

            var account = d.StringGet("ACCNT:" + id);

            if (account.HasValue)
            {
                return(new CustomerAccount()
                {
                    CustomerId = id,
                    AccountNo = account
                });
            }

            return(null);
        }
 public async Task Add(string key, string data)
 {
     await redisContext.GetDb().SetAddAsync(key, data);
 }