コード例 #1
0
ファイル: SelectVisitor.cs プロジェクト: mingyaaaa/Brochure
        /// <summary>
        /// Gets the parent express value.
        /// </summary>
        /// <param name="expression">The expression.</param>
        /// <returns>A string.</returns>
        private string GetParentExpressValue(MemberExpression expression)
        {
            string memberName = _dbPrivoder.FormatFieldName(expression.Member.Name);

            if (expression.Expression is MemberExpression memberExpression)
            {
                var str = GetParentExpressValue(memberExpression);
                return($"{str}.{memberName}");
            }
            else if (expression.Expression is ParameterExpression parameterExpression)
            {
                //处理Group类型的问题
                var tableKey = parameterExpression.Type.GetHashCode();
                if (parameterExpression.Type.Name == typeof(IGrouping <,>).Name)
                {
                    return($"{parameterExpression.Type.Name}.{memberName}");
                }
                else
                {
                    TableTypeDic.TryAdd(tableKey, parameterExpression.Type);
                }
                return($"{tableKey}.{memberName}");
            }

            return("");
        }
コード例 #2
0
ファイル: GroupVisitor.cs プロジェクト: mingyaaaa/Brochure
        /// <summary>
        /// Gets the parent express value.
        /// </summary>
        /// <param name="expression">The expression.</param>
        /// <returns>A string.</returns>
        private string GetParentExpressValue(MemberExpression expression)
        {
            if (expression.Expression is MemberExpression memberExpression)
            {
                var str = GetParentExpressValue(memberExpression);
                return($"{str}.{expression.Member.Name}");
            }
            else if (expression.Expression is ParameterExpression parameterExpression)
            {
                var tableKey = parameterExpression.GetHashCode();
                TableTypeDic.TryAdd(tableKey, parameterExpression.Type);
                string memberName = _dbPrivoder.FormatFieldName(expression.Member.Name);
                var    memberStr  = isSetNew ? $".{memberName}" : string.Empty;
                GroupDic.TryAdd($"{typeof(IGrouping<,>).Name}.{_dbPrivoder.FormatFieldName("Key")}{memberStr}", $"{tableKey}.{memberName}");
                return($"{tableKey}.{memberName}");
            }

            return("");
        }