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();
 }