GithubHelp home page GithubHelp logo

Projection with Automapper about unitofwork HOT 8 CLOSED

arch avatar arch commented on September 14, 2024
Projection with Automapper

from unitofwork.

Comments (8)

Wielebny666 avatar Wielebny666 commented on September 14, 2024 5

Hi,
map config:

 CreateMap<Model, ViewModel>()
.ForMember(dest => dest.property, opt => opt.MapFrom(src => src.property));

CreateMap<IPagedList<Model>, IPagedList<ViewModel>>()
.ConvertUsing<PagedListToPagedListConverter<Model, ViewModel>>();

converter class:

public class PagedListToPagedListConverter<T1, T2> : ITypeConverter<IPagedList<T1>, IPagedList<T2>>
    {
        public IPagedList<T2> Convert(
            IPagedList<T1> source,
            IPagedList<T2> destination,
            ResolutionContext context)
        {
            var models = source as PagedList<T1>;
            return PagedList.From(models, c => new List<T2>(Mapper.Map<IEnumerable<T2>>(c)));
        }
    }

from unitofwork.

rigofunc avatar rigofunc commented on September 14, 2024

Maybe, let me try later

from unitofwork.

Wielebny666 avatar Wielebny666 commented on September 14, 2024

Helped You?

from unitofwork.

rigofunc avatar rigofunc commented on September 14, 2024

Good start, thanks

from unitofwork.

attiqeurrehman avatar attiqeurrehman commented on September 14, 2024

Sorry for late reply, I went with GetAll method to get IQueryable and projected it with automapper.

-A

from unitofwork.

georgepaoli avatar georgepaoli commented on September 14, 2024

Thank you @Wielebny666 !!!

from unitofwork.

coskuncinar avatar coskuncinar commented on September 14, 2024

Hello @Wielebny666

I am using this framework
And i dont know how to use the PagedListToPagedListConverter in GetPagedListAsync

Can you open this topic a little more?
Its important subject.
Please help me

from unitofwork.

coskuncinar avatar coskuncinar commented on September 14, 2024

@akinihsan
do you have comments pls?

from unitofwork.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.