我有一个Web API运行存储过程并从表中返回记录。该记录包含一个称为CounterSeq的int字段
[HttpGet]
public IHttpActionResult Get(string Account)
{
// other code for connecting to the SQL seerver and calling the stored procedure
reader = command.ExecuteReader();
List<QueryResult>qresults = new List<QueryResult>();
while (reader.Read())
{
QueryResult qr = new QueryResult();
qr.AccountID = reader["AccountID"].ToString();
qr.CounterSeq = reader["CounterSeq"].ToString("000");
qresults.Add(qr);
}
DbConnection.Close();
return Ok(qresults);
Run Code Online (Sandbox Code Playgroud)
使CounterSeq的响应为“ 001”,“ 010”,“ 100”。它thows像错误No overload for method 'ToString' takes 1 arguments的reader["CounterSeq"].ToString("000");
我有一个调用 Web API 的网站https://www.dreamtrips.com/
如何找到该网站调用不同数据所使用的Web API?
fiddler会给你这个网站调用的Web API URL列表吗?
对我来说,Windows服务是不方便和足够繁琐质疑他们在没有所有的应用程序有效性"关注此文件夹的变化,应对这种变化."
我知道这种过度简化是无知的,为什么会选择通过Web API的Windows服务.
我有一个标准的Web API应用程序.让我们假设在一个动作中我想返回这样的响应:
public IHttpActionResult GetSomething()
{
var model = new Domain.OutcomingModels.Action[1];
return Ok(model);
}
Run Code Online (Sandbox Code Playgroud)
对于model我可以指定为a class或a的对象struct.从我的角度来看,没有理由喜欢struct过class,就性能.
该应用程序将每秒处理数百万客户端的请求.我关心的事情:
我对吗?
问题不在于类和结构之间的一般差异.它是将它们与类似Ok或BadRequest将C#对象转换为序列化对象的方法一起使用.我在问可能的警告.