Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File scoped and explicit enums #19

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

jeffward01
Copy link

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.

@furkandeveloper furkandeveloper self-requested a review October 1, 2022 10:22
@furkandeveloper furkandeveloper self-assigned this Oct 1, 2022
@furkandeveloper furkandeveloper added the enhancement New feature or request label Oct 1, 2022
Comment on lines +38 to +39
var book = await this._unitOfWork.Repository.AddAsync<Book, Guid>(
new Book
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unnecessary 'this' qualifier @jeffward01

AuthorId = entity.Id
});

await this._unitOfWork.Repository.CompleteAsync();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unnecessary 'this' qualifier @jeffward01

[HttpPost("range")]
public async Task<IActionResult> AddAuthorAsync([FromBody] List<AuthorRequestDto> dto)
{
var entity = await this._unitOfWork.Repository.AddRangeAsync<Author, Guid>(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unnecessary 'this' qualifier @jeffward01

[HttpGet("filterable-multiple")]
public async Task<IActionResult> GetFilterableMultipleAsync([FromQuery] AuthorFilterDto dto)
{
var entities = await this._unitOfWork.Repository.GetMultipleAsync<Author, AuthorFilterDto, object>(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unnecessary 'this' qualifier @jeffward01

public async Task<IActionResult> GetIncludeableFilterableMultipleAsync([FromQuery] AuthorFilterDto dto)
{
Func<IQueryable<Author>, IIncludableQueryable<Author, object>> include = a => a.Include(i => i.Books);
var entities = await this._unitOfWork.Repository.GetMultipleAsync<Author, AuthorFilterDto, object>(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unnecessary 'this' qualifier @jeffward01

Comment on lines +120 to +122
var entities = await this._unitOfWork.Repository.GetMultipleAsync<Author>(false);

return this.Ok(entities);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unnecessary 'this' qualifier @jeffward01

Comment on lines +128 to +130
var entities = await this._unitOfWork.Repository.GetMultipleAsync<Author, object>(
false,
select => new
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unnecessary 'this' qualifier @jeffward01

Comment on lines +142 to +145
var entity = await this._unitOfWork.Repository.GetByIdAsync<Author>(true, id);
await this._unitOfWork.Repository.HardDeleteAsync(entity);

return this.NoContent();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unnecessary 'this' qualifier @jeffward01

Comment on lines +151 to +154
var entity = await this._unitOfWork.Repository.GetByIdAsync<Author>(true, id);
await this._unitOfWork.Repository.SoftDeleteAsync<Author, Guid>(entity);

return this.NoContent();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unnecessary 'this' qualifier @jeffward01

Copy link
Owner

@furkandeveloper furkandeveloper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too many unnecessary 'this' qualifiers are used.
All of these need to be removed.

}
public async Task CompleteAsync(CancellationToken cancellationToken = default)
{
await this._context.SaveChangesAsync(cancellationToken)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unnecessary 'this' qualifier @jeffward01

@furkandeveloper
Copy link
Owner

Let the methods using normal bools stay for now. I don't think it's necessary to make a big change in one go.
We will remove it in future versions. @jeffward01

@jeffward01
Copy link
Author

First of all, big thank you for all of your change requests! I would much rather that you mention your opinion and suggest changes, rather than 'just hit accept'. Thank you.

Let the methods using normal bools stay for now. I don't think it's necessary to make a big change in one go.
We will remove it in future versions. @jeffward01

Are the [Obsolete] attributes I added alright?

Remove unnecessary 'this' qualifier

Ahh, your one of these people who dislike this. ❤️ || I understand why people dislike them, I also understand why people like them. No issue at all!

I will remove all of this. keywords AND make an .editorconfig file that is .sln scoped for the library so that the coding standards could be maintained. Please give me a few days to do this

@furkandeveloper
Copy link
Owner

First of all, big thank you for all of your change requests! I would much rather that you mention your opinion and suggest changes, rather than 'just hit accept'. Thank you.

Let the methods using normal bools stay for now. I don't think it's necessary to make a big change in one go.
We will remove it in future versions. @jeffward01

Are the [Obsolete] attributes I added alright?

Remove unnecessary 'this' qualifier

Ahh, your one of these people who dislike this. ❤️ || I understand why people dislike them, I also understand why people like them. No issue at all!

I will remove all of this. keywords AND make an .editorconfig file that is .sln scoped for the library so that the coding standards could be maintained. Please give me a few days to do this

You are right, with .editorconfig these problems can be avoided. We are waiting for you. :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants