EasyRepository.EFCore icon indicating copy to clipboard operation
EasyRepository.EFCore copied to clipboard

File scoped and explicit enums

Open jeffward01 opened this issue 1 year ago • 3 comments

Summary

*** Summary is here ***

Changes made:

  • Changed all files to 'file-scoped' namespaces
  • Resharper automatically formatted the namespaces and using statements
  • Added methods for Enum version of boolean as no tracking
  • Added Obsolete messages
  • Changed a typo of async Task<int> Count(....) to async Task<int> CountAsync(....)
  • Changed the Enum version of the method:
  • Changed only the enum version of the method GetById to use the AsNoTracking option. See below

    public TEntity GetById<TEntity>(bool asNoTracking, object id)
        where TEntity : class
    {
        return this._context.Set<TEntity>()
            .FirstOrDefault(this.GenerateExpression<TEntity>(id));
    }

    /// <inheritdoc />
    public TEntity GetById<TEntity>(EfTrackingOptions asNoTracking, object id)
        where TEntity : class
    {
        var queryable = this.FindQueryable<TEntity>(asNoTracking)
            .FirstOrDefault(this.GenerateExpression<TEntity>(id));

        return queryable;
    }

image

If you want, I can also apply the change to the classic boolean GetById<TEntity>(bool, object) method. I did not want to introduce any breaking changes, so I skipped this on the classic version.

jeffward01 avatar Oct 01 '22 03:10 jeffward01