Data binding 如何绑定";“在飞行中”;NancyFx中的模型数据?

Data binding 如何绑定";“在飞行中”;NancyFx中的模型数据?,data-binding,nancy,Data Binding,Nancy,如何将生成的而非持久性数据添加到响应中 我的回答如下: Get["/GetUserByID/{id}"] = x => { //here are some codes ... return JsonConvert.SerializeObject(userReadRepository.GetUserByID(id), Formatting.Indented);}; 现在我想将生成的值添加到我的响应中,如何才能做到这一点?尝试以下方法: Get["/GetUserByID/{id}"] =

如何将生成的而非持久性数据添加到响应中

我的回答如下:

Get["/GetUserByID/{id}"] = x => {
//here are some codes ...
return JsonConvert.SerializeObject(userReadRepository.GetUserByID(id), Formatting.Indented);};
现在我想将生成的值添加到我的响应中,如何才能做到这一点?

尝试以下方法:

Get["/GetUserByID/{id}"] = x => Response.AsJson(new { user = userReadRepository.GetUserByID(x.id) , foo = "bar" , bar = 124 });