Automapper configuration problem, structural difference - c#

I am struggling to configure automaper for following scenario, where there is an extra level of indirection at the source level.
On DB layer we have structure:
ResultDB (hasa) List<CaseTriageResultDB> and CaseTriageResultDB has a TriageResultDB
On DTO layer we have structure:
ResultDTO (hasa) List<TriageResultDTO>
I want to configure automapper to map ResultDB objects to ResultDTO objects. Here is a (failing) test with dummy classes to demonstrate the problem:
public class TriageResultDB
{
public string Name { get; set; }
public string Description { get; set; }
}
public class CaseTriageResultDB
{
public TriageResultDB TriageResult { get; set; }
}
public class ResultDB
{
public double EstimatedCost { get; set; }
public IEnumerable<CaseTriageResultDB> CaseTriageResults { get; set; }
}
//-- DTOs (ResultDTO -> List<TriageResult>)
public class TriageResultDTO
{
public string Name { get; set; }
public string Description { get; set; }
}
public class ResultDTO
{
public double EstimatedCost { get; set; }
public IEnumerable<TriageResultDTO> TriageResults { get; set; }
}
[TestFixture]
public class MappingTests
{
MapperConfiguration CreateConfig()
{
var config = new MapperConfiguration(cfg =>
{
cfg.CreateMap<TriageResultDB, TriageResultDTO>();
cfg.CreateMap<ResultDB, ResultDTO>();
});
return config;
}
[Test]
public void MapFromDBtoDTO()
{
var config = CreateConfig();
var resultDB = new ResultDB()
{
EstimatedCost = 100,
CaseTriageResults = new List<CaseTriageResultDB>()
{
new CaseTriageResultDB() { TriageResult = new TriageResultDB() { Name = "triageResult1", Description = "description1" }},
new CaseTriageResultDB() { TriageResult = new TriageResultDB() { Name = "triageResult2", Description = "description2" }}
}
};
var mapper = config.CreateMapper();
var dto = mapper.Map<ResultDTO>(resultDB);
Assert.AreEqual(100, dto.EstimatedCost);
Assert.AreEqual("triageResult1", dto.TriageResults.First().Name);
Assert.AreEqual("triageResult2", dto.TriageResults.Last().Name);
}
}

Worked it out myself, something like:
cfg.CreateMap<ResultDB, ResultDTO>()
.ForMember(dto => dto.TriageResults,
opt => opt.MapFrom(db => db.CaseTriageResults.Select(dbTriageResult => dbTriagResult.TriageResult)));

Related

Mapping viewmodel children with parameter AutoMapper

I'm pretty new using AutoMapper and i run into an issue
I have a model like this.
public class StepUp {
public string Example {get;set;}
public string Example2 {get;set;}
public decimal? auxValue { get;set; }
}
But i have two ViewModels as destination
public class NuevoStepUpViewModel()
{
public bool TieneAuxiliar { get; set; }
public string Example { get;set; }
public CargaDatosElectricos CargaDatosElectricos { get; set; }
}
public class CargaDatosElectricos {
public CargaDatosElectricos(bool tieneAuxiliar)
{
TieneAuxiliar = tieneAuxiliar;
}
public readonly bool TieneAuxiliar;
public string Example2 { get; set; }
}
I think some like this:
CreateMap<StepUp,NuevoStepUpViewModel()
.ForMember(x => x.TieneAuxiliar, x => x.MapFrom(c => c.auxValue.HasValue))
.ForMember(x => x.Example, x => x.MapFrom(c => c.Example))
.ForMember(x => x.CargaDatosElectricos.Example2, x => x.MapFrom(c => c.Example2))
.BeforeMap((x,y) => {
x.CargaDatosElectricos = new CargaDatosElectricos(c.auxValue.HasValue);
});
But i'm getting
Expression 'x => x.CargaDatosElectricos.Example2' must resolve to
top-level member and not any child object's properties
How should i create my mapper configuration to do this type of mapping?
There are some errors on your code. You could configure better your mapping using the AfterMap scope instead of BeforeMap to provide a complex configuration. (I am not sure but I think the) AutoMapper will not instance a property where the type is a class. So, you have to do it on the construtor of the destination class (VIewModel) or do it on AfterMap.
The TieneAuxiliar property will not allow you to set a value when it is readonly, so, you will not able to configure a map to this property. I change it to a public classic property.
See the working sample here:
https://dotnetfiddle.net/HSyUVv
using System;
using AutoMapper;
public class Program
{
public static void Main()
{
var config = new MapperConfiguration(cfg =>
{
cfg.CreateMap<StepUp, NuevoStepUpViewModel>()
.ForMember(vm => vm.TieneAuxiliar, opt => opt.MapFrom(e => e.auxValue.HasValue))
.ForMember(vm => vm.Example, opt => opt.MapFrom(e => e.Example))
.AfterMap((e, vm) =>
{
vm.CargaDatosElectricos.Example2 = e.Example2;
});
});
var mapper = config.CreateMapper();
var stepUp = new StepUp()
{
Example = "Example 1",
Example2 = "Example 2",
auxValue = 10m
};
var viewModel = mapper.Map<StepUp, NuevoStepUpViewModel>(stepUp);
Console.WriteLine("SteUp was converted to ViewModel");
Console.WriteLine("TieneAuxiliar: {0}", viewModel.TieneAuxiliar);
Console.WriteLine("Example: {0}", viewModel.Example);
Console.WriteLine("CargaDatosElectricos.TieneAuxiliar: {0}", viewModel.CargaDatosElectricos.TieneAuxiliar);
Console.WriteLine("CargaDatosElectricos.Exemple2: {0}", viewModel.CargaDatosElectricos.Example2);
}
public class StepUp
{
public string Example { get; set; }
public string Example2 { get; set; }
public decimal? auxValue { get; set; }
}
public class NuevoStepUpViewModel
{
public bool TieneAuxiliar { get; set; }
public string Example { get;set; }
public CargaDatosElectricos CargaDatosElectricos { get; set; }
public NuevoStepUpViewModel()
{
this.CargaDatosElectricos = new CargaDatosElectricos();
}
}
public class CargaDatosElectricos
{
public CargaDatosElectricos()
{
}
public bool TieneAuxiliar { get; set; }
public string Example2 { get; set; }
}
}

AutoMapper - map to derived objects depend on condition

I want to map source class to derived (from abstract) destination classes depend on value of some property.
I have the following source classes:
public partial class ApplicationDriver
{
public virtual ICollection<ApplicationDriverEquipment> Equipments { get; set; }
}
public partial class ApplicationDriverEquipment
{
public int Id { get; set; }
[StringLength(256)]
public string Make { get; set; }
[StringLength(256)]
public string Model { get; set; }
[StringLength(256)]
public string Year { get; set; }
[StringLength(256)]
public string VINNumber { get; set; }
[StringLength(256)]
public string PlateNumber { get; set; }
[StringLength(256)]
public string CurrentMileage { get; set; }
[StringLength(256)]
public string Length { get; set; }
public string Type { get; set; }
public int DriverId { get; set; }
public virtual ApplicationDriver Driver { get; set; }
}
I want to map to the following classes, depend on Type parameter:
public class ApplicationDriverDomain
{
public List<ApplicationDriverEquipmentAbstractDomain> Equipments { get; set; }
}
public abstract class ApplicationDriverEquipmentAbstractDomain
{
public int Id { get; set; }
public string Make { get; set; }
public string Model { get; set; }
public string Year { get; set; }
public string PlateNumber { get; set; }
public string CurrentMileage { get; set; }
public string Type { get; protected set; }
}
public class ApplicationDriverEquipmentTractorDomain : ApplicationDriverEquipmentAbstractDomain
{
public ApplicationDriverEquipmentTractorDomain()
{
Type = ApplicationDriverEquipmentTypeStaticStringsDomain.Tractor;
}
public string VINNumber { get; set; }
}
public class ApplicationDriverEquipmentTrailerDomain : ApplicationDriverEquipmentAbstractDomain
{
public ApplicationDriverEquipmentTrailerDomain()
{
Type = ApplicationDriverEquipmentTypeStaticStringsDomain.Trailer;
}
public string Length { get; set; }
}
public class ApplicationDriverEquipmentStraightTruckDomain : ApplicationDriverEquipmentAbstractDomain
{
public ApplicationDriverEquipmentStraightTruckDomain()
{
Type = ApplicationDriverEquipmentTypeStaticStringsDomain.StraightTruck;
}
public string VINNumber { get; set; }
public string Length { get; set; }
}
public class ApplicationDriverEquipmentCargoVanDomain : ApplicationDriverEquipmentAbstractDomain
{
public ApplicationDriverEquipmentCargoVanDomain()
{
Type = ApplicationDriverEquipmentTypeStaticStringsDomain.CargoVan;
}
public string VINNumber { get; set; }
public string Length { get; set; }
}
I try to do it:
ApplicationDriverEquipmentAbstractDomain GetEquipment(Infrastructure.Asset.ApplicationDriverEquipment infrastructure)
{
ApplicationDriverEquipmentAbstractDomain result = null;
var config = new MapperConfiguration(cfg => cfg.AddProfile<AutoMapperApplicationModel>());
var mapper = config.CreateMapper();
switch (infrastructure.Type)
{
case ApplicationDriverEquipmentTypeStaticStringsDomain.Tractor:
result = mapper.Map<ApplicationDriverEquipmentTractorDomain>(infrastructure);
break;
case ApplicationDriverEquipmentTypeStaticStringsDomain.Trailer:
result = mapper.Map<ApplicationDriverEquipmentTrailerDomain>(infrastructure);
break;
case ApplicationDriverEquipmentTypeStaticStringsDomain.StraightTruck:
result = mapper.Map<ApplicationDriverEquipmentStraightTruckDomain>(infrastructure);
break;
case ApplicationDriverEquipmentTypeStaticStringsDomain.CargoVan:
result = mapper.Map<ApplicationDriverEquipmentCargoVanDomain>(infrastructure);
break;
}
return result;
}
CreateMap<Infrastructure.Asset.ApplicationDriverEquipment, ApplicationDriverEquipmentTractorDomain>();
CreateMap<Infrastructure.Asset.ApplicationDriverEquipment, ApplicationDriverEquipmentTrailerDomain>();
CreateMap<Infrastructure.Asset.ApplicationDriverEquipment, ApplicationDriverEquipmentStraightTruckDomain>();
CreateMap<Infrastructure.Asset.ApplicationDriverEquipment, ApplicationDriverEquipmentCargoVanDomain>();
CreateMap<Infrastructure.Asset.ApplicationDriverEquipment, ApplicationDriverEquipmentAbstractDomain>()
.Include<Infrastructure.Asset.ApplicationDriverEquipment, ApplicationDriverEquipmentTractorDomain>()
.Include<Infrastructure.Asset.ApplicationDriverEquipment, ApplicationDriverEquipmentTrailerDomain>()
.Include<Infrastructure.Asset.ApplicationDriverEquipment, ApplicationDriverEquipmentStraightTruckDomain>()
.Include<Infrastructure.Asset.ApplicationDriverEquipment, ApplicationDriverEquipmentCargoVanDomain>()
.ForMember(dest => dest.Type, opt => opt.ResolveUsing(GetEquipment))
;
CreateMap<Infrastructure.Asset.ApplicationDriver, ApplicationDriverDomain>()
.ForMember(dest => dest.Equipments, opt => opt.MapFrom(src => src.Equipments));
but I got an error:
"Error mapping types.\r\n\r\nMapping types:\r\nApplicationDriver ->
ApplicationDriverDomain\r\nInfrastructure.Asset.ApplicationDriver ->
Domain.POCO.Application.ApplicationDriverDomain\r\n\r\nType Map
configuration:\r\nApplicationDriver ->
ApplicationDriverDomain\r\nInfrastructure.Asset.ApplicationDriver ->
Domain.POCO.Application.ApplicationDriverDomain\r\n\r\nProperty:\r\nEquipments"
Updated:
So I believe I understand what you are trying to do, and apologies I may have slightly led you down the incorrect route. You flow is basically to distinguish what infrastructure type the source object is and then create that type of object. Also you need to understand the two different Mapper set up ways.
In the first part of your code you are trying to set it up with an instance of the Mapper but then using my Static style of using the Mapper.Map I would recommend always using the static style so that you have the ability to do some more dynamic ways of pulling mapping profiles in.
Mapper.Initialize(cfg => cfg.AddProfile<AutomapperRules>());
var domain = Mapper.Map<Domain.ApplicationDriverEquipmentTractorDomain>(inf);
Next you only need to reference that a mapping type from the underlying source to the domain types in your profile i.e.
CreateMap<ApplicationDriverEquipmentInfrastructure, ApplicationDriverEquipmentTractorDomain>();
CreateMap<ApplicationDriverEquipmentInfrastructure, ApplicationDriverEquipmentTrailerDomain>();
CreateMap<ApplicationDriverEquipmentInfrastructure, ApplicationDriverEquipmentStraightTruckDomain>();
CreateMap<ApplicationDriverEquipmentInfrastructure, ApplicationDriverEquipmentCargoVanDomain>();
Then what you need to do is to call your GetEquipment method from the mapping that describes the ApplicationDriver i.e.
CreateMap<ApplicationDriver, ApplicationDriverDomain>()
.ForMember(dest => dest.Equipments, opt => opt.ResolveUsing(x => x.Equipments.Select(GetEquipment)));
private ApplicationDriverEquipmentAbstractDomain GetEquipment(ApplicationDriverEquipmentInfrastructure infrastructure)
{
switch (infrastructure.Type)
{
case "Tractor":
return Mapper.Map<ApplicationDriverEquipmentTractorDomain>(infrastructure);
case "Trailer":
return Mapper.Map<ApplicationDriverEquipmentTrailerDomain>(infrastructure);
case "StraightTruck":
return Mapper.Map<ApplicationDriverEquipmentStraightTruckDomain>(infrastructure);
case "CargoVan":
return Mapper.Map<ApplicationDriverEquipmentCargoVanDomain>(infrastructure);
}
return null;
}
Example Usage:
Mapper.Initialize(cfg => cfg.AddProfile<AutomapperRules>());
var inf = new ApplicationDriverEquipmentInfrastructure()
{
CurrentMileage = "mil",
Length = "123",
Make = "ccc",
Model = "15",
Type = "Tractor",
VINNumber = "vin"
};
var driver = new ApplicationDriver()
{
Equipments = new List<ApplicationDriverEquipmentInfrastructure>() {inf}
};
var domain = Mapper.Map<ApplicationDriverDomain>(driver);
Inheritance in AM works by checking the type of the source, not by using a discriminator. That's what you were supposed to understand from the docs. One way to solve your problem is to pass an existing destination to Map. Created by smth like the GetEquipment method you have there. ApplyBaseMapping is a hack, you use Include/IncludeBase to reuse configuration. Unfortunately you've also hit a bug already fixed in the MyGet build, so the real error was kind of hidden from you. The only way to debug this in your version is by checking the execution plan.

How to design class for abstract json document?

Suppose we have class Request which we want to serialize to json and deserialize from json.
class Request {
public string SessionId { get; set; }
...
public string InnerJson { get; set; }
}
As json it should looks like
{
"SessionId": 1,
...
"InnerJson": {
"some": "json object",
"whatever": 666
}
}
InnerJson is some json document (arbitrary type).
Is it good to use string for InnerJson in Request?
Is there any good way to design Request class?
If you are going for a strongly typed model I'd suggest a factory. For demonstration sake:
public abstract class AbstractOptions { }
public class Options1 : AbstractOptions { public int Whatever { get; set; } }
public class Options2 : AbstractOptions { public string Some { get; set; } }
public class Options3 : AbstractOptions {
[JsonProperty("when")] public DateTime When { get; set; }
[JsonProperty("inner")] public InnerComplexObject Inner { get; set; }
}
public class Request {
[JsonProperty("session-id")] public string SessionId { get; set; }
[JsonProperty("options")] public AbstractOptions Options { get; set; }
}
public class InnerComplexObject { }
then use it like:
var req1 = new Request() { SessionId = "s1", Options = new Options1 { Whatever = 123 } };
var req2 = new Request() { SessionId = "s2", Options = new Options2 { Some = "some" } };
var req3 = new JToken.Request() { SessionId = "s3", Options = new Options3 { When = DateTime.UtcNow, Inner = new InnerComplexObject() } };
Otherwise, for flexibility, keep InnerJson a string and use dynamic queries.

Automapper with resolver throwing "Error mapping types"

We have a class inside another class as a property which needs to be mapped using Automapper. We have written a resolver which will map the source class properties to destinationMember properties. I have written the below logic which is not working.
We are receiving the following error.
Error mapping types.
Mapping types: SubscriberDTO -> Subscriber
ConsoleAutomapperTestHarness.SubscriberDTO ->
ConsoleAutomapperTestHarness.Subscriber
Type Map configuration: SubscriberDTO -> Subscriber
ConsoleAutomapperTestHarness.SubscriberDTO ->
ConsoleAutomapperTestHarness.Subscriber
Property: SubscriberSettings
using AutoMapper; //5.1.1.0
using System;
namespace ConsoleAutomapperTestHarness
{
public class Program
{
public static void Main(string[] args)
{
SubscriberDTO subDTO = new SubscriberDTO();
subDTO.AllowAddPFA = true;
subDTO.AllowAutoPay = true; ;
subDTO.SubscriberID = 10000;
subDTO.FirstName = "Kishor";
new SubscriberAutoMapper();
Subscriber sub = Mapper.Map<SubscriberDTO, Subscriber>(subDTO);
Console.WriteLine(sub.SubscriberSettings.AllowAddPFA.ToString());
Console.ReadLine();
}
}
public class SubscriberAutoMapper
{
public SubscriberAutoMapper()
{
Mapper.Initialize(cfg => {
cfg.CreateMap<SubscriberDTO, Subscriber>()
.ForMember(dest => dest.SubscriberSettings, opt => opt.ResolveUsing<SubscriberAutoMapperResolver>());
});
Mapper.AssertConfigurationIsValid();
}
}
public class SubscriberAutoMapperResolver : IValueResolver<SubscriberDTO, Subscriber, Settings>
{
public Settings Resolve(SubscriberDTO source, Subscriber destination, Settings destMember, ResolutionContext context)
{
//line which is working.
return new Settings() { AllowAddPFA = source.AllowAddPFA };
//line which is not working
// var result = context.Mapper.Map<SubscriberDTO, Settings>(source);
// var result = Mapper.Map<SubscriberDTO, Settings>(source);
//var result = Mapper.Map<SubscriberDTO, Settings>(source,destMember);
//var result = context.Mapper.Map<SubscriberDTO, Settings>(source, destMember, context);
//return result;
}
}
public class Subscriber
{
public int SubscriberID { get; set; }
public Settings SubscriberSettings { get; set; }
public string FirstName { get; set; }
}
public class Settings
{
public bool AllowEnrollment { get; set; }
public bool AllowAutoPay { get; set; }
public bool AllowAddPFA { get; set; }
}
public class SubscriberDTO
{
public int SubscriberID { get; set; }
public string FirstName { get; set; }
public bool AllowEnrollment { get; set; }
public bool AllowAutoPay { get; set; }
public bool AllowAddPFA { get; set; }
}
}
The ValueResolver seems overkill honestly, you can drop it completely and achieve the desired result with as little as this (given that the default AutoMapper behaviour makes it redundant to explicitly specify properties when they have the same name, as in most of your models basically):
Mapper.Initialize(cfg => {
cfg.CreateMap<SubscriberDTO, Subscriber>()
.ForMember(d => d.SubscriberSettings, o => o.MapFrom(s => s));
cfg.CreateMap<SubscriberDTO, Settings>();
});

Automapper - Missing type map configuration or unsupported mapping

Been struggling with this for a day now to no avail. I am new to Automapper and I am trying to map a EF domain object with a viewModel but I receive the following exception:
Missing type map configuration or unsupported mapping.\r\n\r\nMapping types:\r\nCatalogueDefinitionFile -> CatalogueDefinitionFileViewModel\r\nDigital.PriceBuilder.Core.Domain.CatalogueDefinitionFile -> Digital.PriceBuilder.Web.Models.CatalogueDefinitionFileViewModel"}
The domain POCO for CatalogueDefinitionFile is:
public class CatalogueDefinitionFile : BaseEntity
{
public CatalogueDefinitionFile()
{
this.ProductDefinitions = new List<ProductDefinition>();
}
public string TargetApplication { get; set; }
public virtual IList<ProductDefinition> ProductDefinitions { get; set; }
}
Base entity:
public abstract class BaseEntity
{
public BaseEntity()
{
this.CreatedDate = DateTime.Now;
this.UpdatedDate = DateTime.Now;
this.IsActive = true;
}
public int Id { get; set; }
public string Name { get; set; }
public bool IsActive { get; set; }
public DateTime CreatedDate { get; set; }
public string CreatedBy { get; set; }
public DateTime UpdatedDate { get; set; }
public string UpdatedBy { get; set; }
}
I've created a Profile:
public class DomainToViewModelMappingProfile : Profile
{
public override string ProfileName
{
get
{
return "DomainToViewModelMappings";
}
}
public DomainToViewModelMappingProfile()
{
ConfigureMappings();
}
/// <summary>
/// Creates a mapping between source (Domain) and destination (ViewModel)
/// </summary>
private void ConfigureMappings()
{
var config = new MapperConfiguration(cfg => {
cfg.CreateMap<ProductDefinition, ProductDefinitionViewModel>().ReverseMap();
cfg.CreateMap<CatalogueDefinitionFile, CatalogueDefinitionFileViewModel>().ReverseMap();
});
IMapper mapper = config.CreateMapper();
mapper.Map<ProductDefinition, ProductDefinitionViewModel>(new ProductDefinition());
mapper.Map<CatalogueDefinitionFile, CatalogueDefinitionFileViewModel>(new CatalogueDefinitionFile());
}
}
The Profile is reference within a AutoMapperConfiguration class which is then referenced in Global.asax:
public class AutoMapperConfiguration
{
public static void Configure()
{
// Create Automapper profiles
Mapper.Initialize(m =>
{
m.AddProfile<DomainToViewModelMappingProfile>();
m.AddProfile<ViewModelToDomainMappingProfile>();
});
}
}
The viewModel looks like this:
public class CatalogueDefinitionFileViewModel
{
public int Id { get; set; }
public string Name { get; set; }
public string TargetApplication { get; set; }
public bool IsActive { get; set; }
public DateTime CreatedDate { get; set; }
public string CreatedBy { get; set; }
public DateTime UpdatedDate { get; set; }
public string UpdatedBy { get; set; }
public virtual IList<ProductDefinition> ProductDefinitions { get; set; }
}
Then in my controller I have this:
public ActionResult Index()
{
IEnumerable<CatalogueDefinitionFileViewModel> viewModel = null;
IEnumerable<CatalogueDefinitionFile> files;
files = _catalogueDefinitionFileService.GetCatalogueDefinitionFiles();
viewModel = Mapper.Map<IEnumerable<CatalogueDefinitionFile>, IEnumerable<CatalogueDefinitionFileViewModel>>(files);
return View(viewModel);
}
The exception is thrown on
viewModel = Mapper.Map<IEnumerable<CatalogueDefinitionFile>, IEnumerable<CatalogueDefinitionFileViewModel>>(files);
Can someone help me understand why this is happening please?
Thanks in advance.
Your profile doesn't do anything:
public class DomainToViewModelMappingProfile : Profile
{
// etc ...
private void ConfigureMappings()
{
// You are just creating a local mapper config/instance here and then discarding it when it goes out of scope...
var config = new MapperConfiguration(cfg => {
cfg.CreateMap<ProductDefinition, ProductDefinitionViewModel>().ReverseMap();
cfg.CreateMap<CatalogueDefinitionFile, CatalogueDefinitionFileViewModel>().ReverseMap();
});
// I assume this is just test code
IMapper mapper = config.CreateMapper();
mapper.Map<ProductDefinition, ProductDefinitionViewModel>(new ProductDefinition());
mapper.Map<CatalogueDefinitionFile, CatalogueDefinitionFileViewModel>(new CatalogueDefinitionFile());
}
}
Try this:
public class DomainToViewModelMappingProfile : Profile
{
public override string ProfileName
{
get
{
return "DomainToViewModelMappings";
}
}
public DomainToViewModelMappingProfile()
{
ConfigureMappings();
}
/// <summary>
/// Creates a mapping between source (Domain) and destination (ViewModel)
/// </summary>
private void ConfigureMappings()
{
CreateMap<ProductDefinition, ProductDefinitionViewModel>().ReverseMap();
CreateMap<CatalogueDefinitionFile, CatalogueDefinitionFileViewModel>().ReverseMap();
}
}
The Profile type your are inheriting probably relates to a map configuration object (hence having similar/same local methods).
Disclaimer: I've not used Automapper for a while, but the above appears to be your issue.
I just tested and things work fine. The following mapping passes:
Mapper.CreateMap<CatalogueDefinitionFile, CatalogueDefinitionFileViewModel>();
var obj = Mapper.Map<IEnumerable<CatalogueDefinitionFileViewModel>>(new List<CatalogueDefinitionFile>{
new CatalogueDefinitionFile
{
Id = 101,
Name = "test",
TargetApplication = "test",
IsActive = false,
CreatedBy = "test",
CreatedDate = DateTime.Now,
UpdatedBy = "test",
UpdatedDate = DateTime.Now,
ProductDefinitions = new List<ProductDefinition> { new ProductDefinition { MyProperty = 100 } }}
});

Categories