<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using PhotoLife.Data.Contracts;

namespace PhotoLife.Data
{
    public class GenericRepository<T> : IRepository<T>
     where T : class
    {
        public GenericRepository(IPhotoLifeEntities dbContext)
        {
            if (dbContext == null)
            {
                throw new ArgumentNullException("Context cannot be null");
            }

            this.Context = dbContext;
        }

        protected IPhotoLifeEntities Context { get; set; }

        public T GetById(object id)
        {
            return this.Context.DbSet<T>().Find(id);
        }

        public IEnumerable<T> Entities => this.Context.DbSet<T>().ToList();

        public IEnumerable<T> GetAll()
        {
            return this.Context.DbSet<T>().ToList();
        }

        public IEnumerable<T> GetAll(Expression<Func<T, bool>> filterExpression)
        {
            return this.Context.DbSet<T>()
                .Where(filterExpression)
                .ToList();
        }

        public IEnumerable<T> GetAll<T1>(Expression<Func<T, bool>> filterExpression, Expression<Func<T, T1>> sortExpression, bool isAscending)
        {
            return isAscending
                ? this.Context.DbSet<T>()
                    .Where(filterExpression)
                    .OrderBy(sortExpression)
                    .ToList()
                : this.Context.DbSet<T>()
                    .Where(filterExpression)
                    .OrderByDescending(sortExpression)
                    .ToList();
        }

        public IEnumerable<T2> GetAll<T1, T2>(Expression<Func<T, bool>> filterExpression, Expression<Func<T, T1>> sortExpression, Expression<Func<T, T2>> selectExpression)
        {
            return this.Context.DbSet<T>()
                 .Where(filterExpression)
                 .OrderBy(sortExpression)
                 .Select(selectExpression)
                 .ToList();
        }

        public void Add(T entity)
        {
            this.Context.SetAdded(entity);
        }

        public void Update(T entity)
        {
            this.Context.SetUpdated(entity);

        }

        public void Delete(T entity)
        {
            this.Context.SetDeleted(entity);
        }
    }
}
<commit_msg>Remove expression body<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using PhotoLife.Data.Contracts;

namespace PhotoLife.Data
{
    public class GenericRepository<T> : IRepository<T>
     where T : class
    {
        public GenericRepository(IPhotoLifeEntities dbContext)
        {
            if (dbContext == null)
            {
                throw new ArgumentNullException("Context cannot be null");
            }

            this.Context = dbContext;
        }

        protected IPhotoLifeEntities Context { get; set; }

        public T GetById(object id)
        {
            return this.Context.DbSet<T>().Find(id);
        }

        public IEnumerable<T> Entities
        {
            get
            {
                return this.Context.DbSet<T>().ToList();
            }
        }

        public IEnumerable<T> GetAll()
        {
            return this.Context.DbSet<T>().ToList();
        }

        public IEnumerable<T> GetAll(Expression<Func<T, bool>> filterExpression)
        {
            return this.Context.DbSet<T>()
                .Where(filterExpression)
                .ToList();
        }

        public IEnumerable<T> GetAll<T1>(Expression<Func<T, bool>> filterExpression, Expression<Func<T, T1>> sortExpression, bool isAscending)
        {
            return isAscending
                ? this.Context.DbSet<T>()
                    .Where(filterExpression)
                    .OrderBy(sortExpression)
                    .ToList()
                : this.Context.DbSet<T>()
                    .Where(filterExpression)
                    .OrderByDescending(sortExpression)
                    .ToList();
        }

        public IEnumerable<T2> GetAll<T1, T2>(Expression<Func<T, bool>> filterExpression, Expression<Func<T, T1>> sortExpression, Expression<Func<T, T2>> selectExpression)
        {
            return this.Context.DbSet<T>()
                 .Where(filterExpression)
                 .OrderBy(sortExpression)
                 .Select(selectExpression)
                 .ToList();
        }

        public void Add(T entity)
        {
            this.Context.SetAdded(entity);
        }

        public void Update(T entity)
        {
            this.Context.SetUpdated(entity);

        }

        public void Delete(T entity)
        {
            this.Context.SetDeleted(entity);
        }
    }
}

{'fraction_non_alphanumeric': 0.10203653159773252, 'fraction_numerical': 0.002939323955490237, 'mean_word_length': 1.6349557522123894, 'pattern_counts': {'":': 0, '<': 59, '<?xml version=': 0, '>': 60, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '968309', 'n_tokens_mistral': 1281, 'n_tokens_neox': 1237, 'n_words': 236}