Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

UnitOfWork IsolationLevel.ReadCommitted not working #11538


User avatar
0
kansoftware created

Hi,

We tried to enable IsolationLevel.ReadCommitted in app service and found its working for the getall but not for Repository.GetAsync(id) Working for below code: [UnitOfWork(IsolationLevel.ReadCommitted)] public async Task<PagedResultDto<GetCatetoryForViewDto>> GetAll(GetAllCatetoriesInput input) {

        var filteredCatetories = _catetoryRepository.GetAll()
                    .WhereIf(!string.IsNullOrWhiteSpace(input.Filter), e => false || e.Name.Contains(input.Filter) || e.code.Contains(input.Filter))
                    .WhereIf(!string.IsNullOrWhiteSpace(input.NameFilter), e => e.Name.Contains(input.NameFilter))
                    .WhereIf(!string.IsNullOrWhiteSpace(input.codeFilter), e => e.code.Contains(input.codeFilter));

        var pagedAndFilteredCatetories = filteredCatetories
            .OrderBy(input.Sorting ?? "id asc")
            .PageBy(input);

        var catetories = from o in pagedAndFilteredCatetories
                         select new
                         {

                             o.Name,
                             o.code,
                             Id = o.Id
                         };

        var totalCount = await filteredCatetories.CountAsync();

        var dbList = await catetories.ToListAsync();
        var results = new List&lt;GetCatetoryForViewDto&gt;();

        foreach (var o in dbList)
        {
            var res = new GetCatetoryForViewDto()
            {
                Catetory = new CatetoryDto
                {

                    Name = o.Name,
                    code = o.code,
                    Id = o.Id,
                }
            };

            results.Add(res);
        }

        return new PagedResultDto&lt;GetCatetoryForViewDto&gt;(
            totalCount,
            results
        );

    }

Not Working for this one [UnitOfWork(IsolationLevel.ReadCommitted)] public async Task<GetCatetoryForViewDto> GetCatetoryForView(int id) { var catetory = await _catetoryRepository.GetAsync(id);

        var output = new GetCatetoryForViewDto { Catetory = ObjectMapper.Map&lt;CatetoryDto&gt;(catetory) };

        return output;
    }

Please suggest way how we can implement the same.

Regards, Harshit


3 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @kansoftware

    • Do you use SQL Server ?
    • Could you share the error message ?

    Thanks,

  • User Avatar
    0
    kansoftware created

    Yes We are using SQL Server. No errors its showing uncommitted records also. So, isolation level mentioned as ReadCommitted is not working

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @kansoftware

    Could you send an email to [email protected] about this problem ? We can arrange an online meeting and check this problem on your project.

    Thanks,