Exemple #1
0
        public IQueryable <T> GetAll(bool trackChanges = true)
        {
            var result = !trackChanges?_context.Set <T>().AsNoTracking() : _context.Set <T>();


            if (trackChanges == true && result != null)
            {
                foreach (var record in result)
                {
                    var(collections, references) = GetEntityNames();

                    // Eager load all the tables referenced by the generic type T
                    foreach (var entity in collections)
                    {
                        _context.Entry(record).Collection(entity).Load();
                    }

                    foreach (var entity in references)
                    {
                        _context.Entry(record).Reference(entity).Load();
                    }
                }
            }

            return(result);
        }
 public void Create(T entity) => _context.Set <T>().Add(entity);