Example #1
0
        protected override void DataOperation(GStatsSession session, Dictionary <string, string> recv)
        {
            using (var db = new retrospyContext())
            {
                var result = from p in db.Pstorage
                             where p.Profileid == _profileid && p.Dindex == _dindex && p.Ptype == _ptype
                             select p;

                Pstorage ps;
                if (result.Count() == 0)
                {
                    //insert a new record in database
                    ps           = new Pstorage();
                    ps.Dindex    = _dindex;
                    ps.Profileid = _profileid;
                    ps.Ptype     = _ptype;
                    ps.Data      = _keyValueStr;
                    db.Pstorage.Add(ps);
                }
                else if (result.Count() == 1)
                {
                    //update an existed record in database
                    ps      = result.First();
                    ps.Data = _keyValueStr;
                }

                db.SaveChanges();
            }
        }
Example #2
0
        protected override void DataOperation()
        {
            using (var db = new retrospyContext())
            {
                var result = from p in db.Pstorage
                             where p.Profileid == _request.ProfileID &&
                             p.Dindex == _request.DataIndex &&
                             p.Ptype == (uint)_request.StorageType
                             select p;

                Pstorage ps;
                if (result.Count() == 0)
                {
                    //insert a new record in database
                    ps           = new Pstorage();
                    ps.Dindex    = _request.DataIndex;
                    ps.Profileid = _request.ProfileID;
                    ps.Ptype     = (uint)_request.StorageType;
                    ps.Data      = _request.KeyValueString;
                    db.Pstorage.Add(ps);
                }
                else if (result.Count() == 1)
                {
                    //update an existed record in database
                    ps      = result.First();
                    ps.Data = _request.KeyValueString;
                }

                db.SaveChanges();
            }
        }