emitmapper

EmitMapper and List

戏子无情 提交于 2019-12-21 21:28:16
问题 It's the first time that I use EmitMapper. I have a list of object ex: Customer and I would like to map this list in a ienumerable of CustomerDTO how can I do that? Tnx 回答1: It's straightforward if you have a list and want to convert it to list of DTOs: var mapper = ObjectMapperManager.DefaultInstance.GetMapper<Customer, CustomerDTO>(); IEnumerable<CustomerDTO> dtos = listOfCustomer.Select(mapper.map); The preblem is when the list is in another object, for example User and UserDTO: class User

Emit Mapper Flattering with Custom Converters

∥☆過路亽.° 提交于 2019-12-12 02:27:37
问题 With this configuration for some reason Conver function of Custom Converter is not called when using FlatteringConfig from EmitMapper Samples. It is called, when DefaultMapConfig is used. The configuration: var userMapper = ObjectMapperManager.DefaultInstance.GetMapper<User, UserModel>( new FlatteringConfig().ConvertGeneric(typeof(IList<>), typeof(IList<>), new DefaultCustomConverterProvider(typeof(EntityListToModelListConverter<,>)))); Any ideas about the potential reason? Solution Look at

From AutoMapper to Emit Mapper

妖精的绣舞 提交于 2019-12-10 17:29:37
问题 I've recently discovered AutoMapper for bridging ViewModels and my actual DB objects. I use it in the way decribed here: http://automapper.codeplex.com/wikipage?title=Projection&referringTitle=Home I've discovered Emit Mapper to :), but I can't find anytning similar to (where I can specify custom projecting rules): .ForMember(dest => dest.EventDate, opt => opt.MapFrom(src => src.EventDate.Date)) Thanks in advance! 回答1: For the Record this is the best solution that I came across on how to do

Object copy approaches in .net: Auto Mapper, Emit Mapper, Implicit Operation, Property Copy

跟風遠走 提交于 2019-11-28 23:32:23
If some one knows any more ways of doing this in .NET and also what is your opinions about that approaches? Which approach you choose and why? Here is the tests of different ways of object copy in .NET. Tests Related to this original thread: How to copy value from class X to class Y with the same property name in c#? So, here it is, you can run it yourself: static void Main(string[] args) { Student _student = new Student(); _student.Id = 1; _student.Name = "Timmmmmmmmaaaahhhh"; _student.Courses = new List<int>(); _student.Courses.Add(101); _student.Courses.Add(121); Stopwatch sw = new

Emit mapper vs valueinjecter or automapper performance

走远了吗. 提交于 2019-11-28 06:52:43
I have spent some time comparing this three mappers and it is interesting why so big performance diffrenece between emitmapper and any of valueinjecter or automapper(last two comparable by performance). From benchmark test in emitmapper solution (1000000 iterations): Auto Mapper (simple): 38483 milliseconds Emit Mapper (simple): 118 milliseconds Handwritten Mapper (simple): 37 milliseconds Auto Mapper (Nested): 53800 milliseconds Emit Mapper (Nested): 130 milliseconds Handwritten Mapper (Nested): 128 milliseconds Auto Mapper (Custom): 49587 milliseconds Emit Mapper (Custom): 231 milliseconds

Object copy approaches in .net: Auto Mapper, Emit Mapper, Implicit Operation, Property Copy

青春壹個敷衍的年華 提交于 2019-11-27 16:10:18
问题 If some one knows any more ways of doing this in .NET and also what is your opinions about that approaches? Which approach you choose and why? Here is the tests of different ways of object copy in .NET. Tests Related to this original thread: How to copy value from class X to class Y with the same property name in c#? So, here it is, you can run it yourself: static void Main(string[] args) { Student _student = new Student(); _student.Id = 1; _student.Name = "Timmmmmmmmaaaahhhh"; _student

Which is faster: Automapper, Valuinjector, or manual mapping? To what degree is each one faster? [closed]

柔情痞子 提交于 2019-11-27 13:48:38
问题 Suppose I have this object in my DAL (ORM etc) public class Student { public string Name {get;set;} public string Address {get;set;} public string Phone {get;set;} public Parent Parent {get;set;} } public class Parent { public string Name {get;set;} public string Address {get;set;} public string Phone {get;set;} } And I have a ViewModel that looks like this public class StudentDetailVM { public string Name {get;set;} public string Address {get;set;} public string Phone {get;set;} public

Emit mapper vs valueinjecter or automapper performance

戏子无情 提交于 2019-11-27 05:43:09
问题 I have spent some time comparing this three mappers and it is interesting why so big performance diffrenece between emitmapper and any of valueinjecter or automapper(last two comparable by performance). From benchmark test in emitmapper solution (1000000 iterations): Auto Mapper (simple): 38483 milliseconds Emit Mapper (simple): 118 milliseconds Handwritten Mapper (simple): 37 milliseconds Auto Mapper (Nested): 53800 milliseconds Emit Mapper (Nested): 130 milliseconds Handwritten Mapper