Esempio n. 1
0
        public void Post([FromBody] Comment value)
        {
            var yc = new YummyContext();
            int k  = yc.Comments.Max(coms => coms.id);

            value.id = k + 1;
            yc.Comments.Add(value);
            yc.SaveChanges();
        }
Esempio n. 2
0
        public void Can_trace_commands()
        {
            using (var context = new YummyContext())
            {
                context.Products.Add(
                    new YummyProduct
                        {
                            Name = "Pineapple Lumps"
                        });

                using (var commandTracer = new CommandTracer())
                {
                    context.SaveChanges();

                    var interceptedCommand = commandTracer.Commands.Single();

                    Assert.Equal(
                        "insert [dbo].[YummyProducts]([Id], [Name])\r\nvalues (@0, @1)\r\n",
                        interceptedCommand.CommandText);
                    Assert.Equal(2, interceptedCommand.Parameters.Count());
                }
            }
        }
Esempio n. 3
0
        public void Can_trace_commands()
        {
            using (var context = new YummyContext())
            {
                context.Products.Add(
                    new YummyProduct
                {
                    Name = "Pineapple Lumps"
                });

                using (var commandTracer = new CommandTracer())
                {
                    context.SaveChanges();

                    var interceptedCommand = commandTracer.Commands.Single();

                    Assert.Equal(
                        "insert [dbo].[YummyProducts]([Id], [Name])\r\nvalues (@0, @1)\r\n",
                        interceptedCommand.CommandText);
                    Assert.Equal(2, interceptedCommand.Parameters.Count());
                }
            }
        }