Пример #1
0
        /// <summary>
        /// 设置查询的条件
        /// </summary>
        /// <param name="whereCompiler"></param>
        /// <param name="chainProperties"></param>
        /// <param name="propertyName"></param>
        protected virtual string GetFeildNameAndAddJoins(WhereCompilerInfo whereCompiler, IList <OrmPropertyInfo> chainProperties, string propertyName)
        {
            var property = chainProperties[chainProperties.Count - 1];

            if (whereCompiler.Table.Joins != null)
            {
                whereCompiler.AddJoins(chainProperties);
            }
            var fieldName = whereCompiler.GetFieldName(property, propertyName);

            return(fieldName);
        }
Пример #2
0
        /// <summary>
        /// 转换一对多
        /// </summary>
        /// <param name="whereCompiler"></param>
        /// <param name="match"></param>
        /// <param name="propertyName"></param>
        /// <param name="chainProperties"></param>
        /// <returns></returns>
        protected virtual WhereCompilerInfo TranslateManyWhere(WhereCompilerInfo whereCompiler, Match match,
                                                               string propertyName, IList <OrmPropertyInfo> chainProperties)
        {
            var m       = Regex.Match(match.Value, BreakersPattern);
            var subText = m.Value.Trim().Substring(1, m.Value.Length - 2);

            if (whereCompiler.Table.Joins != null)
            {
                whereCompiler.AddJoins(chainProperties);
            }
            var subWhereCompiler = TranslateQueryManyWhere(whereCompiler, subText, chainProperties, propertyName);

            return(subWhereCompiler);
        }
Пример #3
0
        /// <summary>
        /// 添加函数
        /// </summary>
        /// <param name="havingCompiler"></param>
        /// <param name="match"></param>
        /// <param name="key"></param>
        protected virtual void AppendHavingMethod(WhereCompilerInfo havingCompiler, Match match, string key)
        {
            var m = Regex.Match(match.Value, BreakersPattern);

            if (!m.Success)
            {
                return;
            }
            var propertyName    = m.Value.Trim('(').Trim(')');
            var chainProperties = havingCompiler.Object.GetChainProperties(propertyName);

            havingCompiler.AddJoins(chainProperties);
            havingCompiler.Builder.Append(key.Equals("Average") ? "Avg" : key);
            if (key.Equals("Count"))
            {
                havingCompiler.Builder.Append("1)");
            }
            else
            {
                Translate(havingCompiler, string.Format("{0})", propertyName));
            }
        }