Пример #1
0
        static void INSERT(TSQLV4DataContext dc)
        {
            ProductCategory prod = new ProductCategory();

            prod.Name         = "Test";
            prod.ModifiedDate = System.DateTime.Now;
            dc.ProductCategory.InsertOnSubmit(prod);
            dc.SubmitChanges();
            var lastrow = (from p in dc.ProductCategory
                           orderby p.ProductCategoryID descending
                           select p).First();

            Console.WriteLine("Id: {0}, Nazwa: {1}", lastrow.ProductCategoryID, lastrow.Name);
            Console.ReadKey();
        }
Пример #2
0
        static void DELETE(TSQLV4DataContext dc)
        {
            var delete = from p in dc.ProductCategory
                         where p.Name.Contains("Test")
                         select p;

            dc.ProductCategory.DeleteAllOnSubmit(delete);
            dc.SubmitChanges();
            var afterChanges = from p in dc.ProductCategory
                               select p;

            foreach (var item in afterChanges)
            {
                Console.WriteLine("Id: {0}, Nazwa: {1}", item.ProductCategoryID, item.Name);
            }
            Console.ReadKey();
        }
Пример #3
0
        static void UPDATE(TSQLV4DataContext dc)
        {
            var update = from p in dc.Product
                         where p.Name.Contains("Tube")
                         select p;
            int i = 0;

            foreach (var item in update)
            {
                item.Name = "Tuuube" + i.ToString();
                i++;
            }
            dc.SubmitChanges();
            var poUpdate = from p in dc.Product
                           where p.Name.Contains("Tuuube")
                           select p;

            foreach (var item in poUpdate)
            {
                Console.WriteLine("Id: {0}, Nazwa: {1}", item.ProductID, item.Name);
            }
            Console.ReadKey();
        }