简体   繁体   中英

Inserting Json TEXT data with NHibernate CreateQuery

I need to save a serialized Json string of varying length to a TEXT column in a Sybase database.

Due to the datatype being TEXT, I cannot use a stored procedure.

NHibernate's CreateQuery seems like it will work BUT the single quotation marks in the Json string is breaking the Query.

As a last resort, I'm considering calling Replace on the single quotation marks and replacing it with a different symbol and then doing the reverse (Restoring the quotes) on the other end before decoding the data.

Is there a better way of achieving what I need to do?

Used string.Replace to replace the single (') quotes with double single quotes ('').

This escapes the single quotes when creating the Sybase SQL query.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM