public virtual void EndMapping(InitContext initContext) { AddObject(); ISupportMapping sm = _dic as ISupportMapping; if (sm != null) { sm.EndMapping(initContext); } }
void IMapDataDestinationList.EndMapping(InitContext initContext) { AddCurrent(); ISupportMapping sm = _list as ISupportMapping; if (sm != null) { sm.EndMapping(initContext); } }
public virtual void InitMapping(InitContext initContext) { ISupportMapping sm = _dic as ISupportMapping; if (sm != null) { sm.BeginMapping(initContext); if (_mapper != initContext.ObjectMapper) { _mapper = initContext.ObjectMapper; } } }
void IMapDataDestinationList.InitMapping(InitContext initContext) { ISupportMapping sm = _list as ISupportMapping; if (sm != null) { sm.BeginMapping(initContext); if (initContext.ObjectMapper != null && _mapper != initContext.ObjectMapper) { _mapper = initContext.ObjectMapper; } } }
public virtual void InitMapping(InitContext initContext) { ISupportMapping sm = _dic as ISupportMapping; if (sm != null) { sm.BeginMapping(initContext); if (_mapper != initContext.ObjectMapper) { _mapper = initContext.ObjectMapper; } } if (_fromSource) { _index = _keyField.ByName? initContext.DataSource.GetOrdinal(_keyField.Name): _keyField.Index; } else { _index = _keyField.ByName? _mapper.GetOrdinal(_keyField.Name, true): _keyField.Index; if (_index < 0) { throw new MappingException( _keyField.ByName? string.Format("Field '{0}' not found.", _keyField.Name): string.Format("Index '{0}' is invalid.", _keyField.Index)); } MemberMapper mm = _mapper[_index]; _typeMismatch = !TypeHelper.IsSameOrParent(typeof(K), mm.Type); Debug.WriteLineIf(_typeMismatch, string.Format( "Member {0} type '{1}' does not match dictionary key type '{2}'.", mm.Name, mm.Type.Name, (typeof(K).Name))); } }
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(); } } }