第一个请求要花时间才能达到服务器API方法,因为它会在启动任务中预先构建服务,有人可以建议我减少在IIS中发布后第一个请求的初始延迟。
// This method gets called by the runtime.
// Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddTransient<IContactService, ContactService>();
services.AddTransient<IPersonService, PersonService>();
services.AddTransient<IDashboardService, DashboardService>();
services.AddTransient<IEmployeeService, EmployeeService>();
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
// In production, the React files will be served from this directory
services.AddSpaStaticFiles(configuration =>
{
configuration.RootPath = "ClientApp/build";
});
}
Run Code Online (Sandbox Code Playgroud)
需要注入100多个服务,这需要花费一些时间进行预建。
我在一个表中有60万条记录和20列。
我想使用LINQ查询,并使用充当“ LIKE”的函数;所以我用了Contains。花费时间(或)会引发超时过期异常。
那么有人可以建议如何解决这个问题吗?我需要比较4列以上。
var majorAgents = new[] { "iPhone", "Android", "iPad" };
List<Person> lstperson =_context.person.where
(w=>majorAgents.Any(x=>w.personLastName.contains(x))
|| majorAgents.Any(x=>w.personFirstName.contains(x))
||w.Address.Any(s=>majorAgents.Contains(s.addressProof)))//Address table referenced as a list
.select(s=> new Person{
s.personId,
s.perosnLastName,
s.personFirstName
}).ToList();
Run Code Online (Sandbox Code Playgroud)