Пример #1
0
        public override IObjectModel ToNewObjectModel(DbSqlQueryExpression sqlQuery, DbTable table, DbMainTableExpression dependentTable, bool ignoreFilters)
        {
            DbColumnAccessExpression cae = ObjectModelHelper.ParseColumnAccessExpression(sqlQuery, table, this.Expression);

            PrimitiveObjectModel objectModel = new PrimitiveObjectModel(this.ObjectType, cae);

            objectModel.NullChecking = ObjectModelHelper.TryGetOrAddNullChecking(sqlQuery, table, this.NullChecking);

            return(objectModel);
        }
Пример #2
0
        public override IObjectActivatorCreator GenarateObjectActivatorCreator(DbSqlQueryExpression sqlQuery)
        {
            int ordinal;

            ordinal = ObjectModelHelper.TryGetOrAddColumn(sqlQuery, this.Expression).Value;

            PrimitiveObjectActivatorCreator activatorCreator = new PrimitiveObjectActivatorCreator(this.ObjectType, ordinal);

            activatorCreator.CheckNullOrdinal = ObjectModelHelper.TryGetOrAddColumn(sqlQuery, this.NullChecking);

            return(activatorCreator);
        }
Пример #3
0
        public IObjectModel ToNewObjectModel(DbSqlQueryExpression sqlQuery, DbTable table, DbMainTableExpression dependentTable)
        {
            ComplexObjectModel newModel = new ComplexObjectModel(this.ConstructorDescriptor);

            newModel.DependentTable = dependentTable;
            newModel.IncludeCollections.AddRange(this.IncludeCollections);

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

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

                newModel.AddConstructorParameter(pi, cae);
            }

            foreach (var kv in this.ComplexConstructorParameters)
            {
                ParameterInfo pi  = kv.Key;
                IObjectModel  val = kv.Value;

                ComplexObjectModel complexMemberModel = val.ToNewObjectModel(sqlQuery, table, dependentTable) as ComplexObjectModel;
                newModel.AddConstructorParameter(pi, complexMemberModel);
            }

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

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

                newModel.AddPrimitiveMember(member, cae);

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

            foreach (var kv in this.ComplexMembers)
            {
                MemberInfo   member = kv.Key;
                IObjectModel val    = kv.Value;

                ComplexObjectModel complexMemberModel = val.ToNewObjectModel(sqlQuery, table, dependentTable) as ComplexObjectModel;
                newModel.AddComplexMember(member, complexMemberModel);
            }

            if (newModel.NullChecking == null)
            {
                newModel.NullChecking = ObjectModelHelper.TryGetOrAddNullChecking(sqlQuery, table, this.NullChecking);
            }

            return(newModel);
        }
Пример #4
0
        public IObjectActivatorCreator GenarateObjectActivatorCreator(DbSqlQueryExpression sqlQuery)
        {
            ComplexObjectActivatorCreator activatorCreator = new ComplexObjectActivatorCreator(this.ConstructorDescriptor);

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

                int ordinal;
                ordinal = ObjectModelHelper.TryGetOrAddColumn(sqlQuery, exp, pi.Name).Value;

                if (exp == this.NullChecking)
                {
                    activatorCreator.CheckNullOrdinal = ordinal;
                }

                activatorCreator.ConstructorParameters.Add(pi, ordinal);
            }

            foreach (var kv in this.ComplexConstructorParameters)
            {
                ParameterInfo pi  = kv.Key;
                IObjectModel  val = kv.Value;

                IObjectActivatorCreator complexMappingMember = val.GenarateObjectActivatorCreator(sqlQuery);
                activatorCreator.ConstructorComplexParameters.Add(pi, complexMappingMember);
            }

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

                int ordinal;
                ordinal = ObjectModelHelper.TryGetOrAddColumn(sqlQuery, exp, member.Name).Value;

                if (exp == this.NullChecking)
                {
                    activatorCreator.CheckNullOrdinal = ordinal;
                }

                activatorCreator.PrimitiveMembers.Add(member, ordinal);
            }

            foreach (var kv in this.ComplexMembers)
            {
                IObjectActivatorCreator complexMemberActivatorCreator = kv.Value.GenarateObjectActivatorCreator(sqlQuery);
                activatorCreator.ComplexMembers.Add(kv.Key, complexMemberActivatorCreator);
            }

            foreach (var kv in this.CollectionMembers)
            {
                IObjectActivatorCreator collectionMemberActivatorCreator = kv.Value.GenarateObjectActivatorCreator(sqlQuery);
                activatorCreator.CollectionMembers.Add(kv.Key, collectionMemberActivatorCreator);
            }

            if (activatorCreator.CheckNullOrdinal == null)
            {
                activatorCreator.CheckNullOrdinal = ObjectModelHelper.TryGetOrAddColumn(sqlQuery, this.NullChecking);
            }

            return(activatorCreator);
        }