Exemplo n.º 1
0
        public static ZhihuEntity GetDbcontext()
        {
            ZhihuEntity Entity = CallContext.GetData("ZhihuEntity") as ZhihuEntity;

            if (Entity == null)
            {
                Entity = new ZhihuEntity();
                CallContext.SetData("ZhihuEntity", Entity);
            }
            return(Entity);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 将队列中的用户信息持久化
 /// </summary>
 public void SaveUser()
 {
     using (ZhihuEntity Entity = new ZhihuEntity())
     {
         string json = RedisManage.GetUserInfo();
         User   user = SerializeHelper.DeserializeToObject <User>(json);
         Entity.user.Add(user);
         try
         {
             Entity.SaveChanges();
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex.ToString());
         }
     }
 }