/// <summary> /// 映射:创建Dto <see cref="TCreateInputDto"/>——>Entity <see cref="TEntity"/> /// </summary> /// <param name="createInput"></param> /// <returns></returns> protected virtual TEntity MapToEntity(TCreateInputDto createInput) { var entity = RayMapper.Map <TCreateInputDto, TEntity>(createInput); SetIdForGuids(entity);//todo return(entity); }
/// <summary> /// 映射: 编辑Dto <see cref="TUpdateInputDto"/> ——> 实体 <see cref="TEntity"/>. /// 默认使用 <see cref="IRayMapper"/> 实现. /// </summary> protected virtual void MapToEntity(TUpdateInputDto updateInput, TEntity entity) { if (updateInput is IEntityDto <TEntityKey> entityDto) { entityDto.Id = entity.Id; RayMapper.Map(updateInput, entity); return; } TrySetUpdateInputDtoIdByPropertyName(updateInput, entity); RayMapper.Map(updateInput, entity); }
/// <summary> /// 将 <see cref="TEntity"/> 映射为 <see cref="TGetListItemOutputDto"/>. /// 默认使用 <see cref="IRayMapper"/> 进行映射. /// </summary> protected virtual TGetListItemOutputDto MapToGetPageOutputDto(TEntity entity) { return(RayMapper.Map <TEntity, TGetListItemOutputDto>(entity)); }
/// <summary> /// 将 <see cref="TEntity"/> 映射为 <see cref="TGetDetailOutputDto"/>. /// 默认使用 <see cref="IRayMapper"/> 进行映射. /// </summary> protected virtual TGetDetailOutputDto MapToGetOutputDto(TEntity entity) { return(RayMapper.Map <TEntity, TGetDetailOutputDto>(entity)); }