Пример #1
0
        /// <summary>
        /// 添加sqlmap
        /// </summary>
        /// <param name="info"></param>
        public void Add(SqlMapInfo info, bool refresh = false)
        {
            if (refresh == true)
            {
                var v = SqlMaps.FirstOrDefault(p => p.Path == info.Path);
                if (v != null)
                {
                    Statement tmp = null;
                    foreach (var st in v.Statements)
                    {
                        statements.TryRemove(st.FullSqlId, out tmp);
                    }

                    SqlMaps.Remove(v);
                }
            }
            if (SqlMaps.Count(p => p.Path == info.Path) < 1)
            {
                SqlMaps.Add(info);

                foreach (var st in info.Statements)
                {
                    statements[st.FullSqlId] = st;
                }
            }
        }
Пример #2
0
        public override void Load(XmlElement config)
        {
            base.Load(config);

            this.Id = config.GetAttribute("id");
            foreach (XmlElement cfg in config.SelectNodes("//cache"))
            {
                var cache = ConfigContext.GetXmlConfigData(cfg, () =>
                {
                    return(new Cache {
                        Scope = this
                    });
                });
                Caches.Add(cache.Id, cache);
            }
            foreach (XmlElement cfg in config.SelectNodes("//sqlmap"))
            {
                var sqlMap = ConfigContext.GetXmlConfigData(cfg, () =>
                {
                    return(new SqlMap {
                        Scope = this
                    });
                });
                SqlMaps.Add(sqlMap.Id, sqlMap);
            }
        }
Пример #3
0
 public SqlMap GetSqlMap(string scope)
 {
     if (!SqlMaps.TryGetValue(scope, out var sqlMap))
     {
         throw new SmartSqlException($"Can not find SqlMap.Scope:{scope}");
     }
     return(sqlMap);
 }
Пример #4
0
        public void AddOrSetSqlMapInfo(SqlMapInfo sm)
        {
            var v = SqlMaps.FirstOrDefault(p => p.Path == sm.Path && p.Scope == sm.Scope);

            if (v != null)
            {
                //Statement tmp = null;
                //foreach (var st in v.Statements)
                //{
                //    statements.TryRemove(st.FullSqlId, out tmp);
                //}

                SqlMaps.Remove(v);
            }

            SqlMaps.Add(sm);
        }