日期:2014-05-20  浏览次数:20987 次

linq 事务查询
怎么用同一个事务查出刚刚修改的记录?

            Console.WriteLine("----------begin Add");
            using (TransactionScope ts = new TransactionScope())
            {
                using (DbAppDataContext db = new DbAppDataContext())
                {

                    t2 tt2 = new t2() { key = "8", value = "8" };

                    db.t2.InsertOnSubmit(tt2);

                    var tt = from t in db.t2 orderby t.key select t;
                    var tw = tt.Where(t => t.key == "8");

                    foreach (var t in tw)
                    {
                        Console.WriteLine(string.Format("key:{0} value:{1}", t.key, t.value));
                    }

                    //db.SubmitChanges();
                }
                ts.Complete();
            }
            Console.WriteLine("----------End Add");
            Console.Read();