Beispiel #1
0
 public void BulkDelete()
 {
     using (var context = new EntitiesModel())
     {
         context.OpenAccessDemoEntities.DeleteAll();
         
     }
 }
Beispiel #2
0
        public void NormalDelete()
        {
            using (var context = new EntitiesModel())
            {
                foreach (var item in context.OpenAccessDemoEntities)
                {
                    context.Delete(item);
                }

                context.SaveChanges();
            }
        }
Beispiel #3
0
        public MemoryStream SerializeToBinaryStream(string employeeFName)//memory stream 
        {
            BinaryFormatter formatter = new BinaryFormatter();

            MemoryStream stream = new MemoryStream();

            using (var dbContext = new EntitiesModel())
            {
                Employee customer = dbContext.Employees.Where(e => e.FirstName == employeeFName).First();

                var sentQueryToServer = customer.FirstName;

                formatter.Serialize(stream, customer);
            }

            return stream;
        }
Beispiel #4
0
        //HW3

        public void Insert100000EntitiesInDB()
        {
            using (var context = new EntitiesModel())
            {
                ulong id = 1;
                int counter = 0;
                while (counter < 100000)
                {
                    id += 7;
                    var row = new OpenAccessDemoEntity()
                    {
                        Name = id + "Demo"
                    };

                    context.Add(row);

                    counter += 1;
                    context.SaveChanges();
                }
            }
        }