예제 #1
0
        public void delete(KnygosDataSet1 dataSet, int n)
        {
            //dataSet.Table.Rows.Remove(dataSet.Table[n]);

            using (LibraryDataEntities2 dataEntities = new LibraryDataEntities2())
            {
                Knygo knygo = (from c in dataEntities.Knygos
                               where c.Id == n
                               select c).FirstOrDefault();


                dataEntities.Knygos.Remove(knygo);
                dataEntities.SaveChanges();
            }
        }
예제 #2
0
        public void AddBook(String autorius, String pavadinimas)
        {
            using (LibraryDataEntities2 dataEntities = new LibraryDataEntities2())
            {
                List <int> idList = dataEntities.Knygos.Select(x => x.Id).ToList();

                Knygo knygo = new Knygo()
                {
                    Id          = idList.Last() + 1,
                    Autorius    = autorius,
                    Pavadinimas = pavadinimas
                };

                dataEntities.Knygos.Add(knygo);
                dataEntities.SaveChanges();
            }
        }