private static void SetPocoProperteyValue <T>(T poco, IDataReader reader, AdvanceMember p, TypeAccessor accessor, IJsonSerializer jsonSerializer = null, IXmlSerializer xmlSerializer = null, ICsvSerializer csvSerializer = null) { var isDynamic = (typeof(IDynamicMetaObjectProvider).IsAssignableFrom(typeof(T))); var value = reader.GetValue(reader.GetOrdinal(p.GetActualMemberName())); if (isDynamic) { DynamicObjectHelper.AddProperty(poco as ExpandoObject, p.GetActualMemberName(), value); return; } if (value.GetType().Name != p.Member.Type.Name && value.GetType() != typeof(DBNull)) { var type = p.Member.Type; if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable <>)) { type = Nullable.GetUnderlyingType(type); } if (type == null) { type = p.Member.Type; } if (p?.SqlCustomAttritube?.SerializableType != null && p?.SqlCustomAttritube?.SerializableType != SerializableType.NONE) { switch (p.SqlCustomAttritube.SerializableType) { case SerializableType.XML: value = xmlSerializer?.DeserializeFromString(value.ToString(), type); break; case SerializableType.JSON: value = jsonSerializer?.DeserializeFromString(value.ToString(), type); break; case SerializableType.CSV: value = csvSerializer?.DeserializeFromString(value.ToString(), type); break; case SerializableType.NONE: value = !type.IsEnum ? Convert.ChangeType(value, type, null) : System.Enum.Parse(type, value.ToString(), true); break; default: break; } } else { value = !type.IsEnum ? Convert.ChangeType(value, type, null) : System.Enum.Parse(type, value.ToString(), true); } } try { accessor[poco, p.Member.Name] = value is DBNull ? null : value; } catch (Exception error) { // this property may not be settable Console.WriteLine(error.Message); } }