/// <summary> /// The <see cref="DatabaseRecord"/> method invoked for each record for its respective dataset. /// </summary> /// <param name="dr">The <see cref="DatabaseRecord"/>.</param> public override void DatasetRecord(DatabaseRecord dr) { if (dr == null) { throw new ArgumentNullException(nameof(dr)); } if (_coll == null) { _coll = new List <TItem>(); } switch (_idTypeCode) { case ReferenceDataIdTypeCode.Int32: _coll.Add((TItem)ReferenceDataManager.Current[typeof(TItem)].GetById(dr.GetValue <int>(_columnName)) !); break; case ReferenceDataIdTypeCode.Int64: _coll.Add((TItem)ReferenceDataManager.Current[typeof(TItem)].GetById(dr.GetValue <long>(_columnName)) !); break; case ReferenceDataIdTypeCode.Guid: _coll.Add((TItem)ReferenceDataManager.Current[typeof(TItem)].GetById(dr.GetValue <Guid>(_columnName)) !); break; case ReferenceDataIdTypeCode.String: _coll.Add((TItem)ReferenceDataManager.Current[typeof(TItem)].GetById(dr.GetValue <string>(_columnName)) !); break; } }
/// <summary> /// The <see cref="DatabaseRecord"/> method invoked for each record for its respective dataset. /// </summary> /// <param name="dr">The <see cref="DatabaseRecord"/>.</param> void IMultiSetArgs.DatasetRecord(DatabaseRecord dr) { if (_coll == null) { _coll = new List <TItem>(); } switch (_idTypeCode) { case ReferenceDataIdTypeCode.Int32: _coll.Add((TItem)ReferenceDataManager.Current[typeof(TItem)].GetById(dr.GetValue <int>(_columnName))); break; case ReferenceDataIdTypeCode.Guid: _coll.Add((TItem)ReferenceDataManager.Current[typeof(TItem)].GetById(dr.GetValue <Guid>(_columnName))); break; } }
/// <summary> /// Sets the source property value from <see cref="DatabaseRecord"/>. /// </summary> /// <param name="value">The source value.</param> /// <param name="dr">The <see cref="DatabaseRecord"/>.</param> /// <param name="operationType">The single <see cref="Mapper.OperationTypes"/> being performed to enable selection.</param> public void SetSrceValue(TSrce value, DatabaseRecord dr, OperationTypes operationType) { if (value == null) { throw new ArgumentNullException(nameof(value)); } if (dr == null) { throw new ArgumentNullException(nameof(dr)); } if (!OperationTypes.HasFlag(operationType)) { return; } if (_mapFromDbOverride != null) { typeof(TSrce).GetProperty(SrcePropertyName).SetValue(value, _mapFromDbOverride(dr, value, operationType)); return; } TSrceProperty val = default(TSrceProperty); if (Mapper != null) { var em = (IDatabaseMapper)Mapper; val = (TSrceProperty)em.MapFromDb(dr, operationType, this); } else { int index = dr.GetOrdinal(DestPropertyName); if (!dr.IsDBNull(index)) { if (Converter != null) { val = (TSrceProperty)Converter.ConvertToSrce(Convert.ChangeType(dr.DataRecord.GetValue(index), Converter.DestUnderlyingType)); } else { val = dr.GetValue <TSrceProperty>(index); } } } SetSrceValue(value, val, operationType); }