小编Gau*_*san的帖子

在第一次请求时,Asp.net Core 2.2变慢

第一个请求要花时间才能达到服务器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多个服务,这需要花费一些时间进行预建。

c#-3.0 typescript2.0 asp.net-core-2.0 angular

7
推荐指数
1
解决办法
843
查看次数

在Linq中使用多个包含花费时间来加载性能问题

我在一个表中有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)

c# linq

5
推荐指数
1
解决办法
160
查看次数

标签 统计

angular ×1

asp.net-core-2.0 ×1

c# ×1

c#-3.0 ×1

linq ×1

typescript2.0 ×1