Esempio n. 1
0
        public static keyValue <string, string> Convert(LambdaExpression expression, charStream stream)
        {
            converter converter = new converter();

            converter.create(expression, stream);
            return(new keyValue <string, string>(converter.FirstMemberName, converter.FirstMemberSqlName));
        }
Esempio n. 2
0
        public static keyValue <string, string> Convert(LambdaExpression expression)
        {
            converter converter = new converter();
            string    sql       = converter.Create(expression);

            return(new keyValue <string, string>(converter.FirstMemberName, sql));
        }
Esempio n. 3
0
        /// <summary>
        /// 委托关联表达式转SQL表达式
        /// </summary>
        /// <param name="expression">委托关联表达式</param>
        /// <param name="isCache">是否缓存</param>
        /// <param name="nameType">获取参数名称方式</param>
        /// <returns>SQL表达式,参数成员名称集合</returns>
        public static keyValue <string, list <string> > Convert(LambdaExpression expression, bool isCache, getNameType nameType)
        {
            nameCache cache;

            if (isCache && expressionCache.TryGetValue(expression, out cache))
            {
                string sql = cache[nameType];
                if (sql != null)
                {
                    return(new keyValue <string, list <string> >(sql, cache.ParameterMemberNames));
                }
                converter converter = new converter(expression, nameType);
                cache[nameType]            = sql = converter.sql;
                cache.ParameterMemberNames = converter.parameterMemberNames;
                return(new keyValue <string, list <string> >(sql, cache.ParameterMemberNames));
            }
            else
            {
                converter converter = new converter(expression, nameType);
                string    sql       = converter.sql;
                if (isCache)
                {
                    expressionCache[expression] = cache = new nameCache();
                    cache.ParameterMemberNames  = converter.parameterMemberNames;
                    cache[nameType]             = sql;
                }
                return(new keyValue <string, list <string> >(sql, converter.parameterMemberNames));
            }
        }