Mapster icon indicating copy to clipboard operation
Mapster copied to clipboard

Can't generate combined model

Open DifficultNick opened this issue 2 years ago • 0 comments

I am trying to generate a model that will combine two classes (named MainContext and TechContext). So I've created another class that contains two properties of this classes:

public class CombinedContext
{
	public MainContext MainContext { get; set; }
	public TechContext TechContext { get; set; }
}

and this is my config:

public class MapsterConfig : ICodeGenerationRegister
{
	public void Register(CodeGenerationConfig config)
	{
		config.AdaptTo("FullContext")
			.ForType<CombinedContext>(
			cfg =>
			{
				cfg.Map(res => res, src => src.MainContext);
				cfg.Map(res => res, src => src.TechContext);
			});
	}
}

like in the bottom of mapping instructions page so, when I run dotnet mapster model -a "assembly.dll" I got an error: Allow only first level member access (eg. obj => obj.Name) (Parameter 'lambda')

How can I do this correctly? Thank you for help and for this product!

DifficultNick avatar Mar 03 '23 02:03 DifficultNick