public TempTableSuffixLease Lease(IEntityType entityType)
        {
            if (entityType == null)
            {
                throw new ArgumentNullException(nameof(entityType));
            }

            EnsureDisposed();

            if (_lookup == null)
            {
                lock (_lock)
                {
                    EnsureDisposed();

                    if (_lookup == null)
                    {
                        _connection = _currentDbContext.Context.Database.GetDbConnection();
                        _lookup     = _cache.LeaseSuffixLookup(_connection);
                    }
                }
            }

            if (!_lookup.TryGetValue(entityType, out var suffixes))
            {
                suffixes = new TempTableSuffixes();
                _lookup.Add(entityType, suffixes);
            }

            return(suffixes.Lease());
        }
Example #2
0
 public TempTableSuffixLease(int suffix, TempTableSuffixes suffixes)
 {
     Suffix    = suffix;
     _suffixes = suffixes ?? throw new ArgumentNullException(nameof(suffixes));
 }