Skip to content

ConstructUsing for generic types doesn't work #507

@omerercelik

Description

@omerercelik

TypeAdapterConfig<PagedList<ExampleEntity>, PagedList<ExampleDto>>.ForType().ConstructUsing(dest => new PagedList<ExampleDto>(new List<ExampleDto>(), 1, 1)); = > its work

TypeAdapterConfig<PagedList<Type>, PagedList<Type>>.ForType().ConstructUsing(dest => new PagedList<Type>(new List<Type>(), 1, 1)); it doesn't work and throw Exception

Exception => System.InvalidOperationException : No default constructor for type 'PagedList`1', please use 'ConstructUsing' or 'MapWith'

pagedlist constructors;

    `public PagedList(IEnumerable<T> items, int page, int size)
        : this(items.AsQueryable(), page, size)
    {
    }

    public PagedList(IEnumerable<T> items, int page, int size, int itemCount)
    {
        BindItems(page, size, itemCount);
        Items = items;
    }

    public PagedList(IQueryable<T> items, int page, int size)
    {
        var itemCount = items.Count();
        BindItems(page, size, itemCount);

        Items = items.PagedBy(page, size).ToList();
    } `

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions