Trying to serialize the results of this Dapper query.
var installations = (await Db.QueryAsync<object>( @"select InstallationID AS Value, Name AS Text
from [AIS].[Abs].Installation" )).ToList();
var inst = JsonSerializer.Serialize( installations );
Message:
System.InvalidCastException : Unable to cast object of type '<GetEnumerator>d__9' to type 'System.Collections.IDictionaryEnumerator'.
Stack Trace:
JsonSerializer.HandleDictionary(JsonClassInfo elementClassInfo, JsonSerializerOptions options, Utf8JsonWriter writer, WriteStack& state)
JsonSerializer.Write(Utf8JsonWriter writer, Int32 originalWriterDepth, Int32 flushThreshold, JsonSerializerOptions options, WriteStack& state)
JsonSerializer.WriteCore(Utf8JsonWriter writer, PooledByteBufferWriter output, Object value, Type type, JsonSerializerOptions options)
JsonSerializer.WriteCore(PooledByteBufferWriter output, Object value, Type type, JsonSerializerOptions options)
JsonSerializer.WriteCoreString(Object value, Type type, JsonSerializerOptions options)
JsonSerializer.Serialize[TValue](TValue value, JsonSerializerOptions options)
Should this work? Works fine in Json.Net.
Trying to serialize the results of this Dapper query.
The error I get is:
Should this work? Works fine in Json.Net.