Esempio n. 1
0
        public void SimpleLinqToSql()
        {
            var pr    = new ProbaDataContext(@"Data Source=MARTYGINPV;Initial Catalog=Proba;Integrated Security=True");
            var tabl3 = new Tabl3
            {
                s1 = "s",
                n1 = 3
            };

            pr.Tabl3s.InsertOnSubmit(tabl3);
            pr.SubmitChanges();
        }
Esempio n. 2
0
        public void MegaLinqToSql()
        {
            DateTime d  = DateTime.Now;
            var      pr = new ProbaDataContext();

            for (int i = 10; i <= 10000; ++i)
            {
                var tabl1 = new Tabl1
                {
                    s1 = "aaa",
                    s2 = "bbb",
                    n1 = i
                };
                pr.Tabl1s.InsertOnSubmit(tabl1);
            }
            pr.SubmitChanges();
            MessageBox.Show(DateTime.Now.Subtract(d).ToString());
        }
Esempio n. 3
0
        public void UpdateLinq()
        {
            var pr = new ProbaDataContext(@"Data Source=MARTYGINPV;Initial Catalog=Proba;Integrated Security=True");
            var ct = from c in pr.Tabl3s
                     where c.n1 > 2
                     orderby c.n1 descending
                     select c;

            foreach (var c in ct)
            {
                if (c.n1 < 5)
                {
                    pr.Tabl3s.DeleteOnSubmit(c);
                }
                else
                {
                    c.s1 = "fff";
                }
            }
            pr.SubmitChanges();
        }