bubibubi / JetEntityFrameworkProvider

Microsoft Access (Jet) Entity Framework provider
89 stars 26 forks source link

SHOW COLUMNS returns a wrong value on IsNullable #17

Closed bubibubi closed 7 years ago

bubibubi commented 7 years ago

This code should work to determine if a column is nullable. Check also EFCore.Jet for more info.

        private static bool GetIsNullable(IDbConnection connection, DataRow rowColumn)
        {
            DataRow fieldRow = GetFieldRow(connection, (string)rowColumn["TABLE_NAME"], (string)rowColumn["COLUMN_NAME"]);

            if (fieldRow == null)
                return Convert.ToBoolean(rowColumn["IS_NULLABLE"]);

            return (bool) fieldRow["AllowDBNull"] && Convert.ToBoolean(rowColumn["IS_NULLABLE"]);
        }