I'd like to use automapper to map between my public data contracts and my BD model. And I need to pass a string parameter into my MapProfile and get a description from my property ("Code" in this example). For example: public class Source { public int Code { get; set; } } public class Destination { public string Description { get; set; } } public class Dic { public
我想使用automapper在我的公共数据合同和我的BD模型之间进行映射。 我需要传递一个字符串参数到我的MapProfile中,并从我的属性(本例中为“Code”)获取一个描述。 例如: public class Source { public int Code { get; set; } } public class Destination { public string Description { get; set; } } public class Dic { public static string GetDescription(int code, string tag) { //do
I'm trying to implement the AutoMapper for a new module. I have the MVC model at the web site, I'm working on, and it looks like this: public class MvcModel { public Params Params { get; set; } public Steps Steps { get; set; } } public class Params { public int? RequestId { get; set; } public bool NewClient { get; set; } } public class Steps { public Step1
我试图为一个新模块实现AutoMapper。 我在网站上有MVC模型,我正在研究,看起来像这样: public class MvcModel { public Params Params { get; set; } public Steps Steps { get; set; } } public class Params { public int? RequestId { get; set; } public bool NewClient { get; set; } } public class Steps { public Step1 Step1 { get; set; } public Step2 Step2 { get; set; }
So I am having this issue with automapper. I believe I am close just must be missing something. I have an Employee class that contains Address class and position class: internal class Employee : IPerson { public int Id { get; set; } public string FirstName { get; set; } public string MiddleName { get; set; } public Address Address { get; set; } public Position Position { g
所以我用automapper来解决这个问题。 我相信我近在咫尺,一定会失去一些东西。 我有一个包含Address类和Position类的Employee类: internal class Employee : IPerson { public int Id { get; set; } public string FirstName { get; set; } public string MiddleName { get; set; } public Address Address { get; set; } public Position Position { get; set; } } 我当然想映射到Dto的使用AutoMapp
I have two identical classes in different namespaces: namespace ClassLibrary1 class Class1 { public readonly int field1; public Class1(int value) { field1 = value; } } And the same class definition in namespace ClassLibrary2 . When I try to use AutoMapper, I get this exception: Expression must be writeable Parameter name: left This is the code of AutoMapper: Mapper.CreateMap<C
我在不同的命名空间中有两个相同的类: namespace ClassLibrary1 class Class1 { public readonly int field1; public Class1(int value) { field1 = value; } } 和名称空间ClassLibrary2的相同类定义。 当我尝试使用AutoMapper时,出现以下异常: 表达式必须是可写的参数名称:left 这是AutoMapper的代码: Mapper.CreateMap<ClassLibrary1.Class1, ClassLibrary2.Class1>(); var result = Mapper.Map<
I have the following data model public class Products { public string Name { get; set; } public ICollection<ProductSize> ProductSizes { get; set; } } public class ProductSize { public double UnitSize { get; set; } public ICollection<ProductPackage> ProductPackages { get; set; } } public class ProductPackage { public int ItemsPerPack { get; set; } public ICol
我有以下数据模型 public class Products { public string Name { get; set; } public ICollection<ProductSize> ProductSizes { get; set; } } public class ProductSize { public double UnitSize { get; set; } public ICollection<ProductPackage> ProductPackages { get; set; } } public class ProductPackage { public int ItemsPerPack { get; set; } public ICollection<Prod
I am mapping between two objects, the source contains two strings called Animal and AnimalColor , for instance Animal = "Cat" and AnimalColor = "White" . The destination contains a property Animal which is a class of type Pet which contains two strings, Type And Color Therefore I have the following in my mapper configuration: cfg.CreateMap<SrcPetStore, DestPetStore>(
我在两个对象之间进行映射,源包含两个名为Animal和AnimalColor字符串,例如Animal = "Cat"和AnimalColor = "White" 。 目的地包含一个属性Animal ,它是一个包含两个字符串类型Pet的类, Type和Color 因此,我在映射器配置中具有以下内容: cfg.CreateMap<SrcPetStore, DestPetStore>() .ForMember(dest => dest.Animal, opt => opt.MapFrom(src => new Pet() { Type = src.Animal,
Is it possible in AutoMapper to ignore certain properties while mapping a list? For example, I have two classes Metadata and MetadataInput. Both have the same fields except for destination, "MetadataInput", which has an extra field. Mapper.CreateMap <IList<Metadata>, IList<MetadataInput>>() I've tried to use the formember option but it generates errors, probab
在映射列表时,AutoMapper可能会忽略某些属性吗? 例如,我有两个类Metadata和MetadataInput。 除目标外,它们都具有相同的字段,“MetadataInput”具有额外的字段。 Mapper.CreateMap <IList<Metadata>, IList<MetadataInput>>() 我试过使用formember选项,但它会产生错误,可能是因为当您想要映射列表时,无法使用该属性? 如果是,是否有替代解决方案? 正如Darin Dimitrov所说,你不应该尝试映射列
We recently upgraded AutoMapper and ran into an issue when mapping items a certain way. When I load an NHibernate domain object, and attempt to map my model to it in the following manner: var myPoco = new MyPoco(); var proxy = repository.Load<MyDomainObject>(id); Mapper.Map(myPoco, proxy); I get the following error: Missing type map configuration or unsupported mapping. MyPoco-> My
我们最近升级了AutoMapper,并在以某种方式映射项目时遇到了问题。 当我加载一个NHibernate域对象,并试图按照以下方式将我的模型映射到它: var myPoco = new MyPoco(); var proxy = repository.Load<MyDomainObject>(id); Mapper.Map(myPoco, proxy); 我收到以下错误: Missing type map configuration or unsupported mapping. MyPoco-> MyDomainObjectProxy 但是,如果我使用该方法的以下重载,我不会得到异
We are attempting to create a tool that allows users to map properties between classes and database values. I'd like to use AutoMapper to map from the DataRow to a class, so long as we manually create the mapping for each property. For example cfg.CreateMap<DataRow, SupplierInventory>() .ForMember(m => m.Id, s => s.MapFrom(r => r[ fields.Fir
我们正在尝试创建一个允许用户在类和数据库值之间映射属性的工具。 我想使用AutoMapper从DataRow映射到类,只要我们手动为每个属性创建映射。 例如 cfg.CreateMap<DataRow, SupplierInventory>() .ForMember(m => m.Id, s => s.MapFrom(r => r[ fields.FirstOrDefault(c => c.DestinationTable == nameof(SupplierInventory) && c.D
I'm using Automapper to convert one object to another like this: Mapper.Initialize(cfg => { cfg.RecognizePrefixes("m_n", "m_b", "m_l", "m_ach", "m_wz", "m_sz"); cfg.CreateMap<short[], string>().ConvertUsing(new ShortArrayTypeConverter()); cfg.CreateMap<int, DateTime>().ConvertUsing(new DateTimeTypeConverter()); cfg.CreateMap<SUserInfoApiV4, UserInfo>(); }
我使用Automapper将一个对象转换为另一个对象,如下所示: Mapper.Initialize(cfg => { cfg.RecognizePrefixes("m_n", "m_b", "m_l", "m_ach", "m_wz", "m_sz"); cfg.CreateMap<short[], string>().ConvertUsing(new ShortArrayTypeConverter()); cfg.CreateMap<int, DateTime>().ConvertUsing(new DateTimeTypeConverter()); cfg.CreateMap<SUserInfoApiV4, UserInfo>(); }); Mapper.Asse