public virtual void EndMapping(InitContext initContext)
        {
            AddObject();

            ISupportMapping sm = _dic as ISupportMapping;

            if (sm != null)
            {
                sm.EndMapping(initContext);
            }
        }
Exemple #2
0
        void IMapDataDestinationList.EndMapping(InitContext initContext)
        {
            AddCurrent();

            ISupportMapping sm = _list as ISupportMapping;

            if (sm != null)
            {
                sm.EndMapping(initContext);
            }
        }
Exemple #3
0
        protected IEnumerable <T> ExecuteEnumerable <T>(DbManager db, Type objectType, bool disposeDbManager)
        {
            try
            {
                using (IDataReader rd = db.ExecuteReader())
                {
                    if (rd.Read())
                    {
                        ObjectMapper     dest   = MappingSchema.GetObjectMapper(objectType);
                        DataReaderMapper source = MappingSchema.CreateDataReaderMapper(rd);

                        InitContext ctx = new InitContext();

                        ctx.MappingSchema = MappingSchema;
                        ctx.ObjectMapper  = dest;
                        ctx.DataSource    = source;
                        ctx.SourceObject  = rd;

                        int[]          index   = MappingSchema.GetIndex(source, dest);
                        IValueMapper[] mappers = ctx.MappingSchema.GetValueMappers(source, dest, index);

                        do
                        {
                            T destObject = (T)dest.CreateInstance(ctx);

                            if (ctx.StopMapping)
                            {
                                yield return(destObject);
                            }

                            ISupportMapping smDest = destObject as ISupportMapping;

                            if (smDest != null)
                            {
                                smDest.BeginMapping(ctx);

                                if (ctx.StopMapping)
                                {
                                    yield return(destObject);
                                }
                            }

                            MappingSchema.MapInternal(source, rd, dest, destObject, index, mappers);

                            if (smDest != null)
                            {
                                smDest.EndMapping(ctx);
                            }

                            yield return(destObject);
                        } while (rd.Read());
                    }
                }
            }
            finally
            {
                if (disposeDbManager)
                {
                    db.Dispose();
                }
            }
        }