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(); }
public void ReadLinq() { 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) { MessageBox.Show(c.n1 + @" " + c.s1); } }
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()); }
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(); }