File scoped and explicit enums#19
Conversation
| var book = await this._unitOfWork.Repository.AddAsync<Book, Guid>( | ||
| new Book |
| AuthorId = entity.Id | ||
| }); | ||
|
|
||
| await this._unitOfWork.Repository.CompleteAsync(); |
| [HttpPost("range")] | ||
| public async Task<IActionResult> AddAuthorAsync([FromBody] List<AuthorRequestDto> dto) | ||
| { | ||
| var entity = await this._unitOfWork.Repository.AddRangeAsync<Author, Guid>( |
| [HttpGet("filterable-multiple")] | ||
| public async Task<IActionResult> GetFilterableMultipleAsync([FromQuery] AuthorFilterDto dto) | ||
| { | ||
| var entities = await this._unitOfWork.Repository.GetMultipleAsync<Author, AuthorFilterDto, object>( |
| 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>( |
| var entities = await this._unitOfWork.Repository.GetMultipleAsync<Author>(false); | ||
|
|
||
| return this.Ok(entities); |
| var entities = await this._unitOfWork.Repository.GetMultipleAsync<Author, object>( | ||
| false, | ||
| select => new |
| var entity = await this._unitOfWork.Repository.GetByIdAsync<Author>(true, id); | ||
| await this._unitOfWork.Repository.HardDeleteAsync(entity); | ||
|
|
||
| return this.NoContent(); |
| var entity = await this._unitOfWork.Repository.GetByIdAsync<Author>(true, id); | ||
| await this._unitOfWork.Repository.SoftDeleteAsync<Author, Guid>(entity); | ||
|
|
||
| return this.NoContent(); |
furkandeveloper
left a comment
There was a problem hiding this comment.
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) |
|
Let the methods using normal bools stay for now. I don't think it's necessary to make a big change in one go. |
|
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.
Are the
Ahh, your one of these people who dislike I will remove all of |
You are right, with |
Summary
*** Summary is here ***
Changes made:
async Task<int> Count(....)toasync Task<int> CountAsync(....)AsNoTrackingoption. See belowIf you want, I can also apply the change to the classic
booleanGetById<TEntity>(bool, object)method. I did not want to introduce any breaking changes, so I skipped this on the classic version.