Base solution for your next web application
Open Closed

Unable to get the data from database #6398


User avatar
0
kalidarscope created

I have done all the steps they have mentioned in the following link. "https://docs.aspnetzero.com/documents/zero/latest/Developing-Step-By-Step-Angular#using-getpeople-method-from-angular-component"

But i have changed the table names and variable only. Everything is mapped correctly based on document.

public ListResultDto<SectionsListDto> GetSections(GetSectionsInput input)
        {          
            var sections = _sectionRepository
               .GetAll()
               .WhereIf(
                   !input.Filter.IsNullOrEmpty(),
                    p => p.rec_id.Contains(input.Filter) ||
                    p.s_text.Contains(input.Filter) ||
                    p.t_text.Contains(input.Filter)
                )
                .OrderBy(p => p.rec_id)
                .ThenBy(p => p.s_text)
                .ToList();

            return new ListResultDto<SectionsListDto>(ObjectMapper.Map<List<SectionsListDto>>(sections));
        }

Mark the breakpoint in VS in above method. But didn't get any data from database.


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

    Hi @kalidarscope

    Are you getting an error or just an empty result ?

    Thanks,

  • User Avatar
    0
    kalidarscope created

    Getting empty result. But i have 2 records in database. Tested the connection string also. Everything is fine.

  • User Avatar
    0
    aaron created
    Support Team

    Check the value of AbpSession.TenantId.

  • User Avatar
    0
    kalidarscope created

    I am getting 1 in AbpSession.TenantId.

  • User Avatar
    0
    aaron created
    Support Team

    Check the TenantId of the records.

  • User Avatar
    0
    kalidarscope created

    I am getting above details in the records.

  • User Avatar
    0
    ryancyq created
    Support Team

    i think @aaron was refering to the 2 records in your database. Does the 2 records have TenantId = 1 as well?

  • User Avatar
    0
    kalidarscope created

    I didn't have a TenantId column in my table. Is it must to have?

  • User Avatar
    0
    ryancyq created
    Support Team

    TenantId is not a mandatory field. It is totally fine without it on an entity.

    can you check if the 2 records have IsDeleted=true?

  • User Avatar
    0
    kalidarscope created

    IsDeleted = 1 in my database.

  • User Avatar
    1
    ryancyq created
    Support Team

    this mean that the 2 records are soft deleted. Hence by default repository will not retrieve soft deleted records.

    see https://aspnetboilerplate.com/Pages/Documents/Data-Filters

  • User Avatar
    0
    kalidarscope created

    But i have followed steps mentioned in the document 'https://docs.aspnetzero.com/documents/zero/latest/Developing-Step-By-Step-Angular'. They get the result properly then why i couldn't get it?

  • User Avatar
    0
    aaron created
    Support Team

    Which section shows deleted records?

  • User Avatar
    0
    kalidarscope created

    Sorry, I have used insert query to insert a record in table. While i was inserting, i have marked the IsDeleted = True.

    As you mentioned before i have used using (_unitOfWorkManager.Current.DisableFilter(AbpDataFilters.SoftDelete)). Then i got the records.

    After that i have updated the IsDeleted = False and removed the using (_unitOfWorkManager.Current.DisableFilter(AbpDataFilters.SoftDelete)). But didn't get the data.

  • User Avatar
    0
    aaron created
    Support Team

    Is it still IsDeleted = 1 in your database?

  • User Avatar
    0
    kalidarscope created

    Sorry it was my mistake. Thank you so much @aaron.