示例#1
0
        /// <summary>
        /// Returns a new instace of the Eav Context. InitZoneApp must be called afterward.
        /// </summary>
        private static EavDataController Instance()
        {
            var connectionString = Configuration.GetConnectionString();
            var context = new EavContext(connectionString);
            var dc = new EavDataController {SqlDb = context};
            dc.DbS = new DbShortcuts(dc);
            dc.Versioning = new DbVersioning(dc);
            dc.Entities = new DbEntity(dc);
            dc.Values = new DbValue(dc);
            dc.Attributes = new DbAttribute(dc);
            dc.Relationships = new DbRelationship(dc);
            dc.AttribSet = new DbAttributeSet(dc);
            dc.Publishing = new DbPublishing(dc);
            dc.Dimensions = new DbDimensions(dc);
            dc.Zone = new DbZone(dc);
            dc.App = new DbApp(dc);
            dc.ContentType = new DbContentType(dc);

            dc.SqlDb.AlternateSaveHandler += dc.SaveChanges;

            return dc;
        }
示例#2
0
        /// <summary>
        /// Persists all updates to the data source and optionally resets change tracking in the object context.
        /// Also Creates an initial ChangeLog (used by SQL Server for Auditing).
        /// If items were modified, Cache is purged on current Zone/App
        /// </summary>
        public int SaveChanges(System.Data.Objects.SaveOptions options, EavContext.OriginalSaveChangesEvent baseEvent)
        {
            if (_appId == 0)
                throw new Exception("SaveChanges with AppId 0 not allowed.");

            // enure changelog exists and is set to SQL CONTEXT_INFO variable
            if (Versioning.MainChangeLogId == 0)
                Versioning.GetChangeLogId(UserName);

            var modifiedItems = baseEvent(options);

            if (modifiedItems != 0 && PurgeAppCacheOnSave)
                DataSource.GetCache(ZoneId, AppId).PurgeCache(ZoneId, AppId);

            return modifiedItems;
            throw new NotImplementedException();
        }