Can I save an 'Object' in a SQL Server database?

后端 未结 5 431
傲寒
傲寒 2020-12-04 10:29

I want to save an object (of any type) into a field in a database in SQL Server 2005. Is it possible? Do I have to convert the object into something, like a byte array for e

5条回答
  •  甜味超标
    2020-12-04 10:58

    I would use JSON to convert the object to a string, and store it in a VARCHAR or TEXT field. Not only the data is stored in a human-readable format, but it's also also readable from different languages, since pretty much every mainstream language has a JSON parser available.

    The link I posted has links to several libraries in many languages (including C#), I have used this one a couple times in the past.

提交回复
热议问题