public IMappingObjectExpression ToNewObjectExpression(DbSqlQueryExpression sqlQuery, DbTable table)
        {
            DbColumnAccessExpression cae = null;

            cae = MappingObjectExpressionHelper.ParseColumnAccessExpression(sqlQuery, table, this._exp);

            MappingFieldExpression mf = new MappingFieldExpression(this._type, cae);

            mf.NullChecking = MappingObjectExpressionHelper.TryGetOrAddNullChecking(sqlQuery, table, this.NullChecking);

            return(mf);
        }
Beispiel #2
0
        public IMappingObjectExpression ToNewObjectExpression(DbSqlQueryExpression sqlQuery, DbTable table)
        {
            MappingObjectExpression moe            = new MappingObjectExpression(this.ConstructorDescriptor);
            MappingObjectExpression mappingMembers = this;

            foreach (var kv in this.ConstructorParameters)
            {
                ParameterInfo pi  = kv.Key;
                DbExpression  exp = kv.Value;

                DbColumnAccessExpression cae = null;
                cae = MappingObjectExpressionHelper.ParseColumnAccessExpression(sqlQuery, table, exp, pi.Name);

                moe.AddConstructorParameter(pi, cae);
            }

            foreach (var kv in mappingMembers.ConstructorEntityParameters)
            {
                ParameterInfo            pi  = kv.Key;
                IMappingObjectExpression val = kv.Value;

                IMappingObjectExpression navMappingMember = val.ToNewObjectExpression(sqlQuery, table);
                moe.AddConstructorEntityParameter(pi, navMappingMember);
            }

            foreach (var kv in mappingMembers.SelectedMembers)
            {
                MemberInfo   member = kv.Key;
                DbExpression exp    = kv.Value;

                DbColumnAccessExpression cae = null;
                cae = MappingObjectExpressionHelper.ParseColumnAccessExpression(sqlQuery, table, exp, member.Name);

                moe.AddMemberExpression(member, cae);

                if (exp == this.PrimaryKey)
                {
                    moe.PrimaryKey = cae;
                    if (this.NullChecking == this.PrimaryKey)
                    {
                        moe.NullChecking = cae;
                    }
                }
            }

            foreach (var kv in mappingMembers.SubResultEntities)
            {
                MemberInfo member            = kv.Key;
                IMappingObjectExpression val = kv.Value;

                IMappingObjectExpression navMappingMember = val.ToNewObjectExpression(sqlQuery, table);
                moe.AddNavMemberExpression(member, navMappingMember);
            }

            if (moe.NullChecking == null)
            {
                moe.NullChecking = MappingObjectExpressionHelper.TryGetOrAddNullChecking(sqlQuery, table, this.NullChecking);
            }

            return(moe);
        }