Exemple #1
0
        public EntitySession(OperationContext context, EntitySessionKind kind = EntitySessionKind.ReadWrite,
                             EntitySessionOptions options = EntitySessionOptions.None)
        {
            Context = context;
            Kind    = kind;
            Options = options;

            IsSecureSession = false;
            _appEvents      = Context.App.AppEvents;
            this.Log        = Context.Log;
            // Multithreaded sessions must be readonly
            var isConcurrent = Kind == EntitySessionKind.ConcurrentReadOnly;

            IsReadOnly    = Kind == EntitySessionKind.ReadOnly || isConcurrent;
            RecordsLoaded = new EntityRecordWeakRefTable(isConcurrent);
            // These lists are not used in Readonly sessions
            if (!IsReadOnly)
            {
                RecordsChanged      = new List <EntityRecord>();
                ListsChanged        = new List <IPropertyBoundList>();
                RecordsToClearLists = new HashSet <EntityRecord>();
            }
            _timeService = Context.App.TimeService;
            //This might be reset in SaveChanges
            NextTransactionId = Guid.NewGuid();
            if (Kind != EntitySessionKind.Dummy)
            {
                _dataSource = context.App.DataAccess.GetDataSource(this.Context);
                _appEvents.OnNewSession(this);
            }
        }
Exemple #2
0
        public EntitySession(OperationContext context, EntitySessionOptions options = EntitySessionOptions.Default)
        {
            Context         = context;
            this.Options    = options;
            IsSecureSession = this is Vita.Entities.Authorization.SecureSession;
            _appEvents      = Context.App.AppEvents;
            this.LocalLog   = Context.LocalLog;
            // Multithreaded sessions must be readonly
            var isConcurrent = Options.IsSet(EntitySessionOptions.Concurrent);

            IsReadOnly    = Options.IsSet(EntitySessionOptions.ReadOnly) || isConcurrent;
            _timeService  = Context.App.GetService <ITimeService>();
            _operationLog = Context.App.GetService <IOperationLogService>();
            RecordsLoaded = new EntityRecordWeakRefTable(isConcurrent);
            // These two lists are not used in Readonly sessions
            if (!IsReadOnly)
            {
                RecordsChanged      = new List <EntityRecord>();
                ListsChanged        = new List <IPropertyBoundList>();
                RecordsToClearLists = new HashSet <EntityRecord>();
                ScheduledCommands   = new List <ScheduledLinqCommand>();
            }
            _appEvents.OnNewSession(this);
            //These might be reset in SaveChanges
            NextTransactionId   = Guid.NewGuid();
            TransactionDateTime = _timeService.UtcNow;
            TransactionStart    = _timeService.ElapsedMilliseconds;
        }
Exemple #3
0
 public void SetOption(EntitySessionOptions option, bool on)
 {
     if (on)
     {
         Options |= option;
     }
     else
     {
         Options &= ~option;
     }
 }
Exemple #4
0
 public static bool IsSet(this EntitySessionOptions options, EntitySessionOptions option)
 {
     return((options & option) != 0);
 }