示例#1
0
        public KeyValueStore UpdateValue(string key, string value, string value2, string desc)
        {
            var curr = context.KeyValueStore.Where(t => t.Key == key).FirstOrDefault();

            if (curr != null)
            {
                curr.SetUpdated();
                curr.Value  = value;
                curr.Value2 = value2;
                curr.Desc   = desc;
            }
            else
            {
                curr = new KeyValueStore();
                curr.Init();
                curr.SetCreated();

                curr.Key    = key;
                curr.Value  = value;
                curr.Value2 = value2;
                curr.Desc   = desc;

                context.KeyValueStore.Add(curr);
            }

            context.SaveChanges();

            return(curr);
        }