C# rest的执行速度非常慢
对数据库中的9000个自定义对象调用C# rest的执行速度非常慢,c#,wcf,rest,restsharp,webhttpbinding,C#,Wcf,Rest,Restsharp,Webhttpbinding,对数据库中的9000个自定义对象调用Execute大约需要10秒,这是正常情况吗 var client = new RestClient("http://localhost:8732/carservice"); var request = new RestRequest(Method.GET); request.Resource = "GetCarList"; var response = client.Execute<List<Car>>(request); var
Execute
大约需要10秒,这是正常情况吗
var client = new RestClient("http://localhost:8732/carservice");
var request = new RestRequest(Method.GET);
request.Resource = "GetCarList";
var response = client.Execute<List<Car>>(request);
var client=new RestClient(“http://localhost:8732/carservice");
var请求=新的重新请求(Method.GET);
request.Resource=“GetCarList”;
var response=client.Execute(请求);
使用ms sql的方法和步骤:
public List<Car> GetCarList()
{
using (var context = new CarEntities(DbAccess.connectionString))
{
return context.Car.Include("Owner").Include("Place").Include("Model").ToList<Car>();
}
}
public List GetCarList()
{
使用(var-context=new-carenties(DbAccess.connectionString))
{
返回上下文.Car.Include(“所有者”).Include(“地点”).Include(“模型”).ToList();
}
}
和服务:
[OperationContract]
[WebGet(ResponseFormat=WebMessageFormat.Xml)]
List<Car> GetCarList();
[运营合同]
[WebGet(ResponseFormat=WebMessageFormat.Xml)]
List GetCarList();
什么需要10秒钟-从数据库获取对象或通过网络传输对象?对于第一种情况,我会非常惊讶,除非你是在一些史前硬件上运行,对于第二种情况,它更现实->序列化如此大的容量并通过电线发送可能需要大量的时间。您可能会考虑在服务上实现分页以提高性能。@圣请共享您的解决方案,如果您已经解决了。