1: namespace Data
2: {
3: /// <summary>
4: /// OA数据库基类
5: /// </summary>
6: public abstract class OARepositoryBase
7: {
8: protected Data.OA.LinqOADataContext _db =
(Data.OA.LinqOADataContext)Data.DataContextFactory.Intance("OA");
9:
10: /// <summary>
11: /// 虚方法,子类可以根据自己的逻辑去复写这个方法
12: /// </summary>
13: public virtual void SubmitChanges()
14: {
15: ChangeSet chs = _db.GetChangeSet();
16: if (chs.Deletes.Count > 0
|| chs.Inserts.Count > 0
|| chs.Updates.Count > 0)
17: _db.SubmitChanges();
18: }
19: }
20:
21:
22: }
本文转自博客园张占岭(仓储大叔)的博客,原文链接:LINQTOSQL作为底层ORM框架后,我们的数据基类就变成了这个样子,如需转载请自行联系原博主。