我有3個選擇是這樣的。我已經得到所有3選擇在SQL轉換爲JSON。在mvc中將Dapper結果QueryMultiple轉換爲Json的人員?
public IHttpActionResult GetTest()
{
string sql = $"SELECT 'Ahmad' AS N'Name',\n" +
"1 AS N'Code',\n" +
"0914 AS N'Phone' FOR JSON PATH\n" +
"SELECT 'Alizadeh' AS N'NameFamily',\n" +
"2 AS N'Code',\n" +
"0915 AS N'Phone' FOR JSON PATH\n" +
" \n" +
" SELECT 'Seven' AS N'BookName',\n" +
"3 AS N'Qty',\n" +
"0916 AS N'IBS' FOR JSON PATH";
var info = Connections.QueryMultiple(sql);
return Ok(info);
}
結果是這樣的:
[
{
"Name": "Ahmad",
"Code": 1,
"Phone": 914
},
{
"NameFamily": "Alizadeh",
"Code": 2,
"Phone": 915
},
{
"BookName": "Seven",
"Qty": 3,
"IBS": 916
}
]
我想多個返回數據集並轉換爲JSON。 –