當我創建我的表一個新的記錄,我想生成只是我的新紀錄,somethink像的主ID的JSON響應:{「PrimaryID」:123}ServiceStack如何僅使用主鍵生成Json響應?
實際上我用這個手工製作的功能:
// Inserts a new row into the PatientSession table
public string AddPatientSession(PatientSession p)
{
int id = (int)_dbConnection.Insert<PatientSession>(p, selectIdentity: true);
string Idconvert = id.ToString();
string IdInsert = "{\"PatientSessionId\":" + Idconvert + "}";
return IdInsert;
}
但我認爲這不是最好的辦法,請給我一個建議嗎? 在此先感謝
你可以看一下這個答案http://stackoverflow.com/a/1056127/2392330 – idlerboris