PWMIS.Core/SqlUtil/SqlCache.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Text;
using PWMIS.DataMap.Entity;

namespace PWMIS.Common
{
    /// <summary>
    /// (与具体数据库无关的)SQL查询命令信息
    /// </summary>
    public class SqlInfo
    {
        public string SQL { get; private set; }
        public Dictionary<string, TableNameField> Parameters { get; private set; }
        public System.Data.CommandType CommandType { get; set; }
        public string TableName { get; set; }

        public SqlInfo(string sql)
        {
            this.SQL = sql;
        }

        public SqlInfo(string sql, Dictionary<string, TableNameField> para)
        {
            this.SQL = sql;
            this.Parameters = para;
        }

        private static Dictionary<string, SqlInfo> _dictSqlCache;
        private static object sync_obj = new object();

        private static Dictionary<string, SqlInfo> DictSqlCache
        { 
            get{
                if (_dictSqlCache == null)
                {
                    lock (sync_obj)
                    {
                        if (_dictSqlCache == null)
                        {
                            var temp = new Dictionary<string, SqlInfo>();
                            _dictSqlCache = temp;
                        }
                    }
                }
                return _dictSqlCache;
            }
        }
        /// <summary>
        /// 从缓存中获取项
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static SqlInfo GetFromCache(string key)
        {
            SqlInfo Value = null;
            DictSqlCache.TryGetValue(key, out Value);
            return Value;
        }
        /// <summary>
后面还有 18 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。