PetaPoco icon indicating copy to clipboard operation
PetaPoco copied to clipboard

Default mappers should ignore read-only or unsupported property

Open tkouba opened this issue 6 years ago • 1 comments

Read-only properties should be ignored or handled only in INSERT/UPDATE. But INSERT/UPDATE handling is not supported at all.

Mappers should also check if property type can be handled, eg. implements IConvertible interface, is primitive or value type.

ConventionMapper can contain this code:

MapColumn = (ci, t, pi) =>
{
    // Check if property is supported
    if ((!pi.PropertyType.IsValueType && !typeof(IConvertible).IsAssignableFrom(pi.PropertyType)) || !pi.CanWrite)
        return false;

    // ... rest of code
};

Currently read-only property which is not explicitly marked as ignored throw missing column exception or null reference exception if column exists in database.

tkouba avatar Mar 20 '18 07:03 tkouba

Hi, I am trying to accomplish my first contribution to PetaPoco.

what if we implement the behavior you described in the ColumnInfo class it self?

AhLay avatar Dec 14 '19 16:12 AhLay