protected virtual void Dispose(bool disposing) { if (disposing) { _context?.Dispose(); } }
public virtual void Dispose(bool disposing) { if (!this.disposed) { if (disposing) { db.Dispose(); } this.disposed = true; } }
protected virtual void Dispose(bool disposing) { if (!this.disposed) { if (disposing) { _libraryContext.Dispose(); } } this.disposed = true; }
protected virtual void Dispose(bool disposing) { if (disposing) { if (_context != null) { _context.Dispose(); _context = null; } } }
public void Dispose(bool disposee) { if (disposee) { if (db != null) { db.Dispose(); db = null; } } }
protected virtual void Dispose(bool disposing) { if (_disposed) { return; } if (disposing) { Context?.Dispose(); } _disposed = true; }
public virtual void Dispose(bool disposing) { if (!this.disposed) { if (disposing) { userManager.Dispose(); roleManager.Dispose(); clientManager.Dispose(); db.Dispose(); } this.disposed = true; } }
private bool disposedValue = false; // Для определения избыточных вызовов protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { db.Dispose(); } // TODO: освободить неуправляемые ресурсы (неуправляемые объекты) и переопределить ниже метод завершения. // TODO: задать большим полям значение NULL. disposedValue = true; } }
private bool disposedValue = false; // To detect redundant calls protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { // TODO: dispose managed state (managed objects). } // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below. // TODO: set large fields to null. _dbContext.Dispose(); disposedValue = true; } }
static void Main(string[] args) { Console.WriteLine("Hello World!"); var context = new LibraryContext(); context.Add(new Author() { Id = Guid.NewGuid(), Name = "Santiago Posteguillo" }); context.Add(new Author() { Id = Guid.NewGuid(), Name = "Simon Scarrow" }); context.Add(new Author() { Id = Guid.NewGuid(), Name = "Steven Pressfiel" }); context.Add(new Author() { Id = Guid.NewGuid(), Name = "Orson Scott" }); context.Add(new Author() { Id = Guid.NewGuid(), Name = "John Scalzi" }); context.SaveChanges(); Console.WriteLine(); var author = context.Set <Author>().FirstOrDefault(); Console.WriteLine($"Author - First: {author.Name}"); Console.WriteLine(); Console.WriteLine($"Author - List"); var authors = context.Set <Author>().ToList(); authors.ForEach(a => Console.WriteLine(a.Name)); Console.WriteLine(); Console.WriteLine("Press any key to exit"); var h = Console.ReadLine(); context.Dispose(); }
public async Task AddRangeAsync(IEnumerable <UserBook> userBooks) { var bookIds = userBooks.Select(u => u.BookId); var books = await _context.Book.Where(b => bookIds.Contains(b.Id)).ToListAsync(); foreach (var item in userBooks) { var book = books.Find(b => b.Id == item.BookId); if (book.AvailableCount >= item.Count) { var entity = Mapper.Map <Entities.UserBook>(item); await _context.AddAsync(entity); book.AvailableCount -= item.Count; } else { _context.Dispose(); throw new OrderedBookAvailabilityException("Books available count has been updated!"); } } await _context.SaveChangesAsync(); }
public void Dispose() { libraryContext.Dispose(); }
public void Dispose() { _databaseLibraryContext.Dispose(); }
protected override void Dispose(bool disposing) { context.Dispose(); base.Dispose(disposing); }
public void Dispose() { context.Dispose(); }
public void Dispose() { db.Dispose(); }
static void Main(string[] args) { Console.WriteLine("Hello World!"); var context = new LibraryContext(); context.Database.EnsureDeleted(); context.Database.EnsureCreated(); //context.Database.Migrate(); context.Add(new Author() { Id = Guid.NewGuid(), Name = "Santiago Posteguillo", Books = new List <Book>() { new Book() { Id = Guid.NewGuid(), Name = "Africanus" }, new Book() { Id = Guid.NewGuid(), Name = "Las legiones malditas" } } }); context.Add(new Author() { Id = Guid.NewGuid(), Name = "Simon Scarrow" }); context.Add(new Author() { Id = Guid.NewGuid(), Name = "Steven Pressfiel" }); context.Add(new Author() { Id = Guid.NewGuid(), Name = "Orson Scott" }); context.Add(new Author() { Id = Guid.NewGuid(), Name = "John Scalzi" }); context.SaveChanges(); Console.WriteLine(); var author = context.Set <Author>() .Include(x => x.Books) .FirstOrDefault(); Console.WriteLine($"Author - First: {author.Name}; Books: {string.Join(",", author.Books.Select(b => b.Name))}"); Console.WriteLine(); Console.WriteLine($"Author - List"); var authors = context.Set <Author>().ToList(); authors.ForEach(a => Console.WriteLine(a.Name)); var books = context.Set <Book>().ToList(); Console.WriteLine(); Console.WriteLine("Press enter to exit"); var h = Console.ReadLine(); context.Dispose(); }
public void Dispose() { Db.Dispose(); }
public void Dispose() { _context.Database.EnsureDeleted(); _context.Dispose(); }
public static void Destroy(LibraryContext context) { context.Database.EnsureDeleted(); context.Dispose(); }
Task <NormalResult> TestLogReplication(CancellationToken token) { return(Task <NormalResult> .Run(() => { Replication replication = new Replication(); LibraryChannel channel = this.GetChannel(); try { int nRet = replication.Initialize(channel, out string strError); if (nRet == -1) { return new NormalResult { Value = -1, ErrorInfo = strError } } ; DatabaseConfig.ServerName = "localhost"; DatabaseConfig.DatabaseName = "testrep"; DatabaseConfig.UserName = "******"; DatabaseConfig.Password = "******"; var context = new LibraryContext(); try { nRet = replication.DoCreateOperLogTable( ref context, channel, -1, "19990101", "20201231", LogType.OperLog, true, (message) => { OutputHistory(message); }, token, out string strLastDate, out long last_index, out strError); /* * nRet = replication.DoReplication( * ref context, * channel, * "19990101", * "20201231", * LogType.OperLog, * (message) => * { * OutputHistory(message); * }, * token, * out string strLastDate, * out long last_index, * out strError); */ if (nRet == -1) { return new NormalResult { Value = -1, ErrorInfo = strError } } ; return new NormalResult(); } finally { if (context != null) { context.Dispose(); } } } finally { this.ReturnChannel(channel); } })); }
public void Dispose() { Db.Dispose(); GC.SuppressFinalize(this); }
public void Dispose() { context.Dispose(); GC.SuppressFinalize(this); }
public void Dispose() { _db?.Dispose(); }
public void Dispose() { _dbContext.Dispose(); _controller.Dispose(); }