コード例 #1
0
        private void ResolveMember()
        {
            var exp = expression as MemberExpression;

            ThrowTrue(exp.Expression == null);
            var childExpression     = exp.Expression;
            MapperExpression mapper = GetMapper(exp);
            var fillInfo            = GetFillInfo(childExpression, mapper);
            var mappingFild1Info    = GetMappingFild1Info(childExpression, mapper);
            var mappingFild1Info2   = GetMappingFild2Info(childExpression, mapper);
            var SelectInfo          = GetSelectInfo(expression);
            var entity = this.context.EntityMaintenance.GetEntityInfo(childExpression.Type);

            var isExMapper          = mappingFild1Info2 != null;
            var isFillFild1SameType = fillInfo.Type == mappingFild1Info.Type;
            var isSameProperty      = false;

            if (isExMapper)
            {
                ExtMapper();
            }
            else if (isSameProperty)
            {
            }
            else if (isFillFild1SameType)
            {
                oneToMany();
            }
            else
            {
                oneToOne(fillInfo, mappingFild1Info, mappingFild1Info2, SelectInfo);
            }
        }
コード例 #2
0
        private MapperExpressionInfo GetMappingFild2Info(Expression childExpression, MapperExpression mapper)
        {
            if (mapper.MappingField2Expression == null)
            {
                return(null);
            }
            var exp   = mapper.MappingField2Expression;
            var field = (exp as LambdaExpression).Body;

            if (field is UnaryExpression)
            {
                field = (field as UnaryExpression).Operand;
            }
            var type = ((field as MemberExpression).Expression).Type;

            this.context.InitMappingInfo(type);
            var name      = (field as MemberExpression).Member.Name;
            var entity    = this.context.EntityMaintenance.GetEntityInfo(type);
            var fieldName = entity.Columns.First(it => it.PropertyName == name).DbColumnName;

            return(new MapperExpressionInfo()
            {
                Type = type,
                FieldName = fieldName
            });
        }
コード例 #3
0
        private MapperExpressionInfo GetMappingFild1Info(Expression childExpression, MapperExpression mapper)
        {
            var exp   = mapper.MappingField1Expression;
            var field = (exp as LambdaExpression).Body;

            if (field is UnaryExpression)
            {
                field = (field as UnaryExpression).Operand;
            }
            var type = ((field as MemberExpression).Expression).Type;

            this.context.InitMappingInfo(type);
            var name      = (field as MemberExpression).Member.Name;
            var entity    = this.context.EntityMaintenance.GetEntityInfo(type);
            var fieldName = entity.Columns.First(it => it.PropertyName == name).DbColumnName;
            var array     = (field as MemberExpression).ToString().Split('.').ToList();

            array[array.Count() - 1] = fieldName;
            var filedString = string.Join(".", array);

            return(new MapperExpressionInfo()
            {
                Type = type,
                FieldName = fieldName,
                FieldString = filedString,
                EntityInfo = entity
            });
        }
コード例 #4
0
 private MapperExpressionInfo GetFillInfo(Expression childExpression, MapperExpression mapper)
 {
     this.querybuiler = mapper.QueryBuilder;
     this.context     = mapper.Context;
     this.sqlBuilder  = mapper.SqlBuilder;
     if (this.querybuiler.TableShortName.IsNullOrEmpty())
     {
         this.querybuiler.TableShortName = (childExpression as MemberExpression).Expression.ToString();
     }
     this.context.InitMappingInfo(childExpression.Type);
     return(new MapperExpressionInfo()
     {
         EntityInfo = this.context.EntityMaintenance.GetEntityInfo(childExpression.Type)
     });
 }
コード例 #5
0
        private void ResolveList()
        {
            var methodExpression = expression as MethodCallExpression;
            var callName         = methodExpression.Method.Name;
            var exp = methodExpression.Arguments[0] as MemberExpression;

            ThrowTrue(exp == null);
            var childExpression     = exp;
            MapperExpression mapper = GetMapperMany(exp);
            var fillInfo            = GetFillInfoMany(childExpression, mapper);
            var mappingFild1Info    = GetMappingFild1ManyInfo(childExpression, mapper);
            var mappingFild1Info2   = GetMappingFild2Info(childExpression, mapper);

            //var SelectInfo = GetSelectInfo(expression);
            this.context.InitMappingInfo(childExpression.Expression.Type);
            var entity = this.context.EntityMaintenance.GetEntityInfo(childExpression.Expression.Type);

            oneToMany(callName, entity, childExpression.Expression.ToString(), fillInfo, mappingFild1Info, mappingFild1Info2);
        }