0

I was going through a tutorial on abp.io:
https://docs.abp.io/en/abp/latest/Tutorials/Part-1?UI=MVC#create-the-application-service

and I created the service:

using Abp.Application.Services;

public interface IBookAppService : 
    ICrudAppService< //Defines CRUD methods
        BookDTO , //Used to show books
        Guid, //Primary key of the book entity
        PagedAndSortedResultRequestDto, //Used for paging/sorting on getting a list of books
        CreateUpdateBookDto, //Used to create a new book
        CreateUpdateBookDto> //Used to update a book
{

}

but the interface is showing an error:

The type 'BookDTO' cannot be used as type parameter 'TEntityDto' in the generic type or method 'ICrudAppService<TEntityDto, TPrimaryKey, TGetAllInput, TCreateInput, TUpdateInput>'. There is no implicit reference conversion from 'BookDTO' to 'Abp.Application.Services.Dto.IEntityDto<System.Guid>'.

BookDTO is as follows:

using Volo.Abp.Application.Dtos;

public class BookDTO : AuditedEntityDto<Guid>
{
    public string Name { get; set; }

    public BookType Type { get; set; }
    public DateTime PublishDate { get; set; }
    public float Price { get; set; }
}
aaron
  • 39,695
  • 6
  • 46
  • 102
UDAY SONI
  • 13
  • 5

3 Answers3

1

CreateUpdateBookDto must be the same primary key type.

public class CreateUpdateBookDto: AuditedEntityDto<Guid> {
}
Lasanga Guruge
  • 832
  • 1
  • 5
  • 15
1

You are mixing:

  • Abp.Application.Services.ICrudAppService<TEntityDto, TPrimaryKey, ...>
  • Volo.Abp.Application.Dtos.IEntityDto<TKey>

For ABP Framework (abp.io), use the Volo.Abp package:

  • Volo.Abp.Application.Services.ICrudAppService<TEntityDto, in TKey, ...>

Related: Which is the real ASP.NET Boilerplate project?

Files to change

IBookAppService.cs:

// using Abp.Application.Services;
// using Abp.Application.Services.Dto;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;

BookAppService.cs:

// using Abp.Application.Services;
// using Abp.Application.Services.Dto;
// using Abp.Domain.Repositories;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;

CreateUpdateBookDTO.cs:

// using Abp.AutoMapper;

Acme.BookStore.Application.Contracts.csproj:

<!-- <PackageReference Include="Abp" Version="5.6.0" /> -->
<!-- <PackageReference Include="Abp.AutoMapper" Version="5.6.0" /> -->
<PackageReference Include="Volo.Abp" Version="2.6.2" />
<PackageReference Include="Volo.Abp.AutoMapper" Version="2.6.2" />
aaron
  • 39,695
  • 6
  • 46
  • 102
0

I bumped into the same issue and fixed it by changing the DTO inheritance
from MyDto : AuditedAggregateRoot<Guid>
to MyDto: AuditedEntityDto<Guid>

Ruslan
  • 162
  • 2
  • 13