Пример #1
0
        public async Task InsertSingleProductsEf6(int interactions, Ef6Context ef6Context)
        {
            var listCustomers = new ListTests().ObtenirListProductsAleatoire(interactions, null);

            ef6Context.Products.AddRange(listCustomers);
            await ef6Context.SaveChangesAsync();
        }
Пример #2
0
 public void Save(IPlayer player)
 {
     using (var context = new Ef6Context())
     {
         context.Players.Add(player as Player);
         context.SaveChanges();
     }
 }
Пример #3
0
 public QueriesController(
     DotNetCoreContext dotNetCoreContext,
     Ef6Context ef6Context,
     CustomersWhereAddressCountryAndProductsCount customersWhereAddressCountryAndProductsCount)
 {
     _dotNetCoreContext = dotNetCoreContext;
     _ef6Context        = ef6Context;
     _customersWhereAddressCountryAndProductsCount = customersWhereAddressCountryAndProductsCount;
 }
        public SinglesInserts5()
        {
            var optionsBuilder = new DbContextOptionsBuilder <DotNetCoreContext>();

            optionsBuilder.UseSqlServer(connectionStrings);
            _efCoreContext             = new DotNetCoreContext(optionsBuilder.Options);
            _sqlConnection             = new SqlConnection(connectionStrings);
            _adoServiceBenchmarkDotNet = new SinglesInsertsBenchmarkDotNet();
            _ef6Context = new Ef6Context();
        }
Пример #5
0
        public void Delete(int id)
        {
            using (var context = new Ef6Context())
            {
                try
                {
                    var result = context.Players.Where(p => p.Identity.Id == id).SingleOrDefault();

                    context.Players.Remove(result);
                    context.SaveChanges();
                }

                catch (NullReferenceException e)
                {
                    throw new ArgumentException(e.Message + $" Player with {id} was not found");
                }
            }
        }
Пример #6
0
        public void Update(IPlayer player)
        {
            using (var context = new Ef6Context())
            {
                try
                {
                    var oldPlayer = context.Players.Where(p => p.Id == player.Id).SingleOrDefault();

                    oldPlayer = (Player)player;

                    context.Players.Add(oldPlayer);
                    context.SaveChanges();
                }
                catch (ArgumentException e)
                {
                    throw new ArgumentException(e + " Player was not found");
                }
            }
        }
Пример #7
0
        public IEnumerable <IPlayer> FindAll()
        {
            var players = new List <ApiQueryPlayerResult>();

            using (var context = new Ef6Context())
            {
                players = context.Players
                          .Include(i => i.Identity)
                          .Include(s => s.Scores)
                          .Select(p => new ApiQueryPlayerResult
                {
                    Id     = p.Id,
                    Name   = p.Identity.Name,
                    Scores = p.Scores
                }
                                  ).ToList();
            }

            return(players);
        }
Пример #8
0
        public IPlayer FindOne(int id)
        {
            using (var context = new Ef6Context())
            {
                try
                {
                    return(context.Players.Where(p => p.Id == id)
                           .Include(s => s.Scores)
                           .Select(p => new ApiQueryPlayerResult
                    {
                        Id = p.Id,
                        Name = p.Identity.Name,
                        Scores = p.Scores
                    }
                                   ) as Player);
                }

                catch (NullReferenceException e)
                {
                    throw new ArgumentException(e.Message + $" Player with {id} was not found");
                }
            }
        }
 public Ef6Service(ConsoleHelper consoleHelper, Ef6Context ef6Context, ResultService resultService)
 {
     _consoleHelper = consoleHelper;
     _ef6Context    = ef6Context;
     _resultService = resultService;
 }
 public async Task SelectSingleProductsEf6(int take, Ef6Context ef6Context)
 {
     var rr = await ef6Context.Products.Take(take).ToListEf6Async();
 }
Пример #11
0
 public Querie2Controller(DotNetCoreContext dotNetCoreContext, Ef6Context ef6Context)
 {
     _dotNetCoreContext = dotNetCoreContext;
     _ef6Context        = ef6Context;
 }