Search code examples
npgsql

How to map composite db object to clr object that has less properties?


We perform a Npgsql upgrade from 2.* to 3.2.7.

I want to map a database object "dbObject" that has fields: a,b,c to a clr object "clrObject" that has properties: a,b

I define a mapping as follows:

NpgsqlConnection.MapCompositeGlobally("dbObject",someNameTranslator);

And I get a runtime error that states, that clrObject does not have a property that matches "c" field in dbObject.

Is there a way to omit some fields when mapping dbObject to clrObject?


Solution

  • This isn't possible at the moment - Npgsql requires that your CLR object have all the necessary fields/properties to map to the PostgreSQL property. You can open an issue on http://github.com/npgsql/npgsql to request this.