1

I have a relational table that stores key-value data in the below structure.

KEY        VARCHAR(10)
Value-Text VARCHAR(50)
Value-Date DATETIME
Value      NUMERIC

So for any given key, there will be only one Value column used. This is not a good design in first place. If I have to create a similar key-value pair in mongo where the value field have different data types, what is the best option ? How will it work with the C# driver ?

auth private
  • 1,318
  • 1
  • 9
  • 22

1 Answers1

0

As gypsyCoder mentioned, there is no need to store the type as part of the schema. In C#, you can define value as an object in your POCO, and the driver will serialize the value as the underlying type. There are a few exceptions. For example, MongoDB does not support decimal types, so decimals are serialized as strings. However, most primitives will translate between C# and MongoDB nicely.

figabytes
  • 303
  • 1
  • 8