Esempio n. 1
0
        public async Task UpdateAsync()
        {
            List<string> data1 = null;
            var data = await repository.GetAsync(7);
            data.SetUserClaims(s => s.SetValue(DateTime.Now.Ticks.ToString()));
            data.Description = DateTime.Now.Ticks.ToString();
            if (data.Scopes.Count > 1)
            {
                data.Scopes[1].DisplayName = DateTime.Now.Ticks.ToString();
                data.Scopes.RemoveAt(0);
            }
            data.Scopes.Add(new ApiScope(DateTime.Now.Ticks.ToString()));
            data.Scopes.Add(new ApiScope(DateTime.Now.Ticks.ToString()));
            var d = await repository.UpdateAsync(data);

            //性能测试
            //var scope1 = Startup.ConfigureServices().CreateScope();
            //var p = scope1.ServiceProvider;
            //var repository1 = p.GetRequiredServiceByName<IRepository>(typeof(ApiResource).Name);
            //var data = (ApiResource)await repository1.ReadAsync(4);
            //DateTime st = DateTime.Now;
            //for (int i = 0; i < 1000; i++)
            //{
            //    var ddd = p.GetRequiredService<RepositoryDbContext>();

            //    repository1 = p.GetRequiredServiceByName<IRepository>(typeof(ApiResource).Name);
            //    data.UserClaims.SetValue(DateTime.Now.Ticks.ToString());
            //    data.Description = DateTime.Now.Ticks.ToString();
            //    if (data.Scopes.Count > 0)
            //    {
            //        data.Scopes[0].DisplayName = DateTime.Now.Ticks.ToString();
            //        data.Scopes.RemoveAt(0);
            //    }
            //    data.Scopes.Add(new ApiScope(DateTime.Now.Ticks.ToString()));
            //    data.Scopes.Add(new ApiScope(DateTime.Now.Ticks.ToString()));
            //    data = (ApiResource)await repository1.WriteAsync(data);
            //    data = data.Clone<ApiResource>();
            //}
            //var ms = (DateTime.Now - st).TotalMilliseconds;
        }