1、
IRowMapper<UserDto> addressMapper = MapBuilder<UserDto> .MapAllProperties() .Map(p => p.Gender) .WithFunc(rec => rec.IsDBNull(rec.GetOrdinal("gender")) ? Gender.Female : Gender.Male) .Build();
或者:
IRowMapper<UserDto> addressMapper = MapBuilder<UserDto> .MapAllProperties() .Map(p => p.Gender) .WithFunc(rec => (Gender)Enum.ToObject(typeof(Gender), rec.GetOrdinal("gender"))) .Build();