In AutoMapper 8.0 missing ResolveUsing

You don't need to use this expression, you can "Users.Count" and it'll return 0 if the list is empty.


In AutoMapper 8.0 missing ResolveUsing

I also have the same issue and I'm using the following prototype of ResolveUsing:

void ResolveUsing(Func<TSource, TResult> mappingFunction);

Instead of replacing existing code, I preferred to create an extension method:

using System;
using AutoMapper;

namespace myLibrary.Extensions
{
    public static class AutoMapperCompatibilityExtensions
    {
        // Summary:
        //     Resolve destination member using a custom value resolver callback. Used instead
        //     of MapFrom when not simply redirecting a source member This method cannot be
        //     used in conjunction with LINQ query projection
        //
        // Parameters:
        //   resolver:
        //     Callback function to resolve against source type
        public static void ResolveUsing<TSource, TDestination, TMember, TResult>(this IMemberConfigurationExpression<TSource, TDestination, TMember> member, Func<TSource, TResult> resolver) => member.MapFrom((Func<TSource, TDestination, TResult>)((src, dest) => resolver(src)));
    }
}

Later, in my code, I simply referred the namespace:

using myLibrary.Extensions;

...
    ... map.ResolveUsing(s =>  ...
...

Hope this helps.


Replace ResolveUsing with MapFrom, and add one more input parameter to the lambda (TDestination).

.ForMember(d => d.UsersCount, map => map.MapFrom((s,d) => s.Users?.Count ?? 0))