Exemple #1
0
        public static string GetSqlStatementByType(Type type, String crudType, string extTableName = null)
        {
            String key = type.Name + "." + crudType;

            if (!StatementParser.StatementCache.ContainsKey(key))
            {
                string sql = StatementParser.GetMappedStaticSql(key);
                if (sql.Equals(key))
                {
                    switch (crudType)
                    {
                    case "Update":
                        sql = MappingInfo.GetMappingInfo(type, extTableName).Update;
                        break;

                    case "Insert":
                        sql = MappingInfo.GetMappingInfo(type, extTableName).Insert;
                        break;

                    case "Delete":
                        sql = MappingInfo.GetMappingInfo(type).Delete;
                        break;

                    default:
                        throw new Exception("GetSqlStatementByType found Unknow CRUD key: " + key);
                    }
                }
                StatementParser.StatementCache.Insert(key, sql);
            }
            return((string)StatementParser.StatementCache.Get(key));
        }
Exemple #2
0
        private static string ParseDynamicSql(string mapSql, IDictionary <string, object> p, IDictionary <string, string> where)
        {
            SqlItem info = StatementParser.GetMappedStatement(mapSql);

            if (info == null)
            {
                return(mapSql);
            }

            return(info.dynamic(p));//会修改参数p的列表
        }