Пример #1
0
 public SiteRepository()
 {
     _db = new SiteContext();
     // RelationデータをProxyを作成せずに管理する。
     // だからIncludeが必須。
     // Attachはうまくいく!!
     ((IObjectContextAdapter)_db).ObjectContext.ContextOptions.ProxyCreationEnabled = false;
 }
Пример #2
0
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                // free managed resources
                if (_db != null)
                {
                    if (_db.Database.Connection.State != ConnectionState.Closed)
                        _db.Database.Connection.Close();

                    _db.Dispose();
                    _db = null;
                }
            }
        }