I'm migrating my project to use newest Npgsql library (v 8.0.2). I used this construction to map C# type to the Postgres type:
var nameTranslator = new NpgsqlSnakeCaseNameTranslator();;
NpgsqlConnection.GlobalTypeMapper.MapComposite<StockPriceDto>("stock_item_price", nameTranslator);
Now NpgsqlConnection.GlobalTypeMapper is marked as obsolete, so I would like to find an alternative for it with Fluent NHibernate configuration.
In postgres I have a stock_item_price type which is almost one-to-one mapping with StockPriceDto type properties (the only differerence is naming convention).
In database i have procedure like:
CREATE OR REPLACE PROCEDURE public.stock_price_save(list stock_item_price[]) ...
It is called in the code:
command.CommandText = "Call stock_price_save(@list)";
var listParam = command.CreateParameter();
listParam.ParameterName = "list";
listParam.DbType = System.Data.DbType.Object;
listParam.Value = data; //IList<StockPriceDto>
command.Parameters.Add(listParam);
command.ExecuteNonQuery();
It works perfect with NpgsqlConnection.GlobalTypeMapper. I cannot find the way to map the type StockPriceDto to stock_item_price in Fluent NHibernate. Anyone done it before?
The error is: Writing values of 'System.Collections.Generic.List`1[[X.StockPriceDto, X, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' is not supported for parameters having no NpgsqlDbType or DataTypeName. Try setting one of these values to the expected database type..