Exemplo n.º 1
0
        static void Ef6()
        {
            var fixture = new Fixture();

            var item = fixture.CreateMany <Product>(10000);

            Stopwatch stopwatch = new Stopwatch();

            Console.WriteLine("Iniciando comparación");
            Console.WriteLine("==ENTITY FRAMEWORK 6==");
            Console.WriteLine("Insertando {0} registros", item.Count());
            using (var transactionScope = new TransactionScope())
            {
                CatalogEntities ctx = new CatalogEntities();

                stopwatch.Start();
                ctx.Product.AddRange(item);
                ctx.SaveChanges();
                stopwatch.Stop();

                Console.WriteLine("Duracion {0} ms ", stopwatch.ElapsedMilliseconds);
                Console.WriteLine("Duracion {0} se ", stopwatch.Elapsed.Seconds);
                Console.WriteLine("Duracion {0} mi ", stopwatch.Elapsed.Minutes);
                stopwatch.Reset();

                Console.WriteLine("Obteniendo TODO los registros");
                stopwatch.Start();
                var reponse = ctx.Product;
                stopwatch.Stop();
                Console.WriteLine("Se obtuvo {0} en una duracion de {1} ms", reponse.Count(),
                                  stopwatch.ElapsedMilliseconds);
                Console.WriteLine("Se obtuvo {0} en una duracion de {1} se", reponse.Count(), stopwatch.Elapsed.Seconds);
                Console.WriteLine("Se obtuvo {0} en una duracion de {1} mi", reponse.Count(), stopwatch.Elapsed.Minutes);
            }
        }
Exemplo n.º 2
0
        public static void Pdf(int StudentID, int GrupaID, int Semestru, string FileName)
        {
            //Creating iTextSharp Table from the DataTable data

            using (var context = new CatalogEntities())
            {
                using (var dbContextTransaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        var tabel = context.usp_catalog_sesiunea_x(StudentID, GrupaID, Semestru);
                        // var tabel  = from a in context.CATALOG_CU_NOTE_TEMPORAR
                        //             select a;

                        // context.CATALOG_CU_NOTE_TEMPORAR.ToString();



                        // Console.Out.WriteLine(query.Count);
                        //Console.Out.WriteLine(query[0].NumeMaterie.ToString());



                        //PdfPTable pdfTable = new PdfPTable(query.Count);//nr of collumns
                        //pdfTable.DefaultCell.Padding = 3;
                        //pdfTable.WidthPercentage = 30;
                        //pdfTable.HorizontalAlignment = Element.ALIGN_LEFT;
                        //pdfTable.DefaultCell.BorderWidth = 1;


                        //for ( int i=0; i< query.Count; i++)
                        //{
                        //    PdfPCell cell = new PdfPCell(new Phrase(query.ElementAt(i).));
                        //    pdfTable.AddCell(cell);
                        //}



                        //foreach (var post in query)
                        //{

                        //}

                        context.SaveChanges();

                        dbContextTransaction.Commit();
                    }
                    catch (Exception)
                    {
                        dbContextTransaction.Rollback();
                    }
                }
            }
        }
Exemplo n.º 3
0
 public ActionResult Register(User user)
 {
     if (ModelState.IsValid)
     { 
         CatalogEntities dc=new CatalogEntities();
         dc.Users.Add(user);
         dc.SaveChanges();
         ModelState.Clear();
         user = null;
         ViewBag.Message = "Registration done successfully";
    }
     return View(user);
 }
Exemplo n.º 4
0
 public ActionResult Register(User user)
 {
     if (ModelState.IsValid)
     {
         CatalogEntities dc = new CatalogEntities();
         dc.Users.Add(user);
         dc.SaveChanges();
         ModelState.Clear();
         user            = null;
         ViewBag.Message = "Registration done successfully";
     }
     return(View(user));
 }