Home

how to insert json to sql 2016?

I have this example where I can select json from sql 2016.

var t=
from a in Trades
where a._id>0
select a;
t.Dump(); and it works

now, how do I insert it now and I am a bit lost as there are too many braces now ..,
Trades t = new Trades(){
trade='
{
"direction": "Short",
"entryprice": 122.618,
"exitprice": 122.556,
"potentialtarget": 0.061309316370273863,
"entrytime": "2016-05-23T08:22:59.1636488-04:00",
"exittime": "2016-05-23T10:35:44.5076809-04:00",
"maxfavourable": 0.23,
"maxagainst": -0.078,
"signal": "EnterShortBounce",
"instrument": "EURJPY"
}'


Comments

  • you need t escape the curly braces or use '@'.


    Trades t = new Trades(){
    trade= @"
    {
    direction: 'Short',
    entryprice: 122.618,
    exitprice: 122.556,
    potentialtarget: 0.061309316370273863,
    entrytime: 2016-05-23T08:22:59.1636488-04:00,
    exittime: 2016-05-23T10:35:44.5076809-04:00,
    maxfavourable : 0.23,
    maxagainst: -0.078,
    signal: 'EnterShortBounce',
    instrument: 'EURJPY'
    }"
Sign In or Register to comment.