Чтение как «System.Object» не поддерживается для полей, имеющих DataType во время адаптера.Fill(dataTable) postgresSQLC#

Место общения программистов C#
Anonymous
Чтение как «System.Object» не поддерживается для полей, имеющих DataType во время адаптера.Fill(dataTable) postgresSQL

Сообщение Anonymous »

Мой код C# обновлен с C# .net6 до .net8. Следующий код работал раньше.

Код: Выделить всё

    using (var adapter = new NpgsqlDataAdapter(sql, context.Database.GetDbConnection() as NpgsqlConnection))
{
var dataTable = new DataTable();
adapter.Fill(dataTable);

return dataTable;
}
После обновления кода до .net 8. Код выдает следующее сообщение об ошибке:

Код: Выделить всё

Reading as 'System.Object' is not supported for fields having DataType
Подробное исключение:

Код: Выделить всё

 
at Npgsql.Internal.AdoSerializerHelpers.g__ThrowReadingNotSupported|0_0(Type type, String displayName, Exception inner)
at Npgsql.Internal.AdoSerializerHelpers.GetTypeInfoForReading(Type type, PostgresType postgresType, PgSerializerOptions options)
at Npgsql.BackendMessages.FieldDescription.g__GetInfoSlow|50_0(Type type, ColumnInfo& lastColumnInfo)
at Npgsql.BackendMessages.FieldDescription.GetInfo(Type type, ColumnInfo& lastColumnInfo)
at Npgsql.BackendMessages.FieldDescription.get_ObjectOrDefaultInfo()
at Npgsql.BackendMessages.FieldDescription.get_FieldType()
at Npgsql.NpgsqlDataReader.GetFieldType(Int32 ordinal)
at System.Data.ProviderBase.SchemaMapping.SetupSchemaWithoutKeyInfo(MissingMappingAction mappingAction, MissingSchemaAction schemaAction, Boolean gettingData, DataColumn parentChapterColumn, Object chapterValue)
at System.Data.ProviderBase.SchemaMapping..ctor(DataAdapter adapter, DataSet dataset, DataTable datatable, DataReaderContainer dataReader, Boolean keyInfo, SchemaType schemaType, String sourceTableName, Boolean gettingData, DataColumn parentChapterColumn, Object parentChapterValue)
at System.Data.Common.DataAdapter.FillMappingInternal(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 schemaCount, DataColumn parentChapterColumn, Object parentChapterValue)
at System.Data.Common.DataAdapter.FillMapping(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 schemaCount, DataColumn parentChapterColumn, Object parentChapterValue)
at System.Data.Common.DataAdapter.FillFromReader(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue)
at System.Data.Common.DataAdapter.Fill(DataTable[] dataTables, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
Любая помощь приветствуется.


Подробнее здесь: https://stackoverflow.com/questions/789 ... -during-ad

Вернуться в «C#»