首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

linq 事宜查询

2013-07-04 
linq 事务查询怎么用同一个事务查出刚刚修改的记录?Console.WriteLine(----------begin Add)using (Tra

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();


[解决办法]
你可以为表设置一个时间戳字段,每次操作表时,都更新一下这个时间戳

热点排行