protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         _context?.Dispose();
     }
 }
Пример #2
0
 public virtual void Dispose(bool disposing)
 {
     if (!this.disposed)
     {
         if (disposing)
         {
             db.Dispose();
         }
         this.disposed = true;
     }
 }
Пример #3
0
 protected virtual void Dispose(bool disposing)
 {
     if (!this.disposed)
     {
         if (disposing)
         {
             _libraryContext.Dispose();
         }
     }
     this.disposed = true;
 }
Пример #4
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (_context != null)
         {
             _context.Dispose();
             _context = null;
         }
     }
 }
Пример #5
0
 public void Dispose(bool disposee)
 {
     if (disposee)
     {
         if (db != null)
         {
             db.Dispose();
             db = null;
         }
     }
 }
Пример #6
0
        protected virtual void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            if (disposing)
            {
                Context?.Dispose();
            }

            _disposed = true;
        }
Пример #7
0
 public virtual void Dispose(bool disposing)
 {
     if (!this.disposed)
     {
         if (disposing)
         {
             userManager.Dispose();
             roleManager.Dispose();
             clientManager.Dispose();
             db.Dispose();
         }
         this.disposed = true;
     }
 }
Пример #8
0
        private bool disposedValue = false; // Для определения избыточных вызовов

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    db.Dispose();
                }

                // TODO: освободить неуправляемые ресурсы (неуправляемые объекты) и переопределить ниже метод завершения.
                // TODO: задать большим полям значение NULL.

                disposedValue = true;
            }
        }
Пример #9
0
        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();
        }
Пример #11
0
        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();
        }
Пример #12
0
 public void Dispose()
 {
     libraryContext.Dispose();
 }
Пример #13
0
 public void Dispose()
 {
     _databaseLibraryContext.Dispose();
 }
Пример #14
0
 protected override void Dispose(bool disposing)
 {
     context.Dispose();
     base.Dispose(disposing);
 }
Пример #15
0
 public void Dispose()
 {
     context.Dispose();
 }
Пример #16
0
 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();
        }
Пример #18
0
 public void Dispose()
 {
     Db.Dispose();
 }
Пример #19
0
 public void Dispose()
 {
     _context.Database.EnsureDeleted();
     _context.Dispose();
 }
 public static void Destroy(LibraryContext context)
 {
     context.Database.EnsureDeleted();
     context.Dispose();
 }
Пример #21
0
        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);
                }
            }));
        }
Пример #22
0
 public void Dispose()
 {
     Db.Dispose();
     GC.SuppressFinalize(this);
 }
Пример #23
0
 public void Dispose()
 {
     context.Dispose();
     GC.SuppressFinalize(this);
 }
Пример #24
0
 public void Dispose()
 {
     _db?.Dispose();
 }
Пример #25
0
 public void Dispose()
 {
     _dbContext.Dispose();
     _controller.Dispose();
 }