Questions tagged [emitmapper]

Emit Mapper is a .NET library for mapping entities, such as objects, DataReaders or SQL commands.

Emit Mapper is an open source library written in C# to map entities to each other. It can be used to fill DTOs, DataRows or Data Access Layer entities.

Emit Mapper is hosted on CodePlex.

Example

A basic example (C#)

public class A {
    string ID { get; set; }
    int Value { get; set; }
}

public class B {
    string ID { get; set; }
    string Value { get; set; }
}

var mapper = ObjectMapperManager.DefaultInstance.GetMapper<A, B>();
B b = mapper.Map(new A { ID = "UniqueKey", Value = 8280 });

Assert.AreEqual(a.ID, b.ID);
Assert.AreEqual(Convert.ToString(a.Value), b.Value);
27 questions
22
votes
1 answer

Emit mapper vs valueinjecter or automapper performance

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…
Igor
  • 255
  • 1
  • 2
  • 6
19
votes
1 answer

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

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…
makerofthings7
  • 60,103
  • 53
  • 215
  • 448
12
votes
3 answers

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

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…
angularrocks.com
  • 26,767
  • 13
  • 87
  • 104
4
votes
1 answer

From AutoMapper to Emit Mapper

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…
artvolk
  • 9,448
  • 11
  • 56
  • 85
4
votes
1 answer

Why is Emit faster than Reflection

I've been reading a lot about emit and how it's so much faster than reflection but haven't been able to find out why. I understand emit is injecting IL code but why is this faster than reflection when doing property mapping like an ORM? Referring…
drac64
  • 53
  • 4
3
votes
2 answers

EmitMapper's List Mapping Issue with Collections

The source class: public class Post { public long ID { get; set; } [Column(TypeName="nvarchar")] [Required] [StringLength(250)] public string Name { get; set; } [Column(TypeName="varchar")] [StringLength(250)] …
fengd
  • 7,551
  • 3
  • 41
  • 44
3
votes
0 answers

Emit Mapper "Nullable object must have a value"

I am using Emit Mapper to copy fields from InternalClass to ExternalClass. public class InternalClass { public int? Id { get; set; } public DateTime? RecordDate {get; set;} } public class ExternalClass { public int Id { get; set; } …
Adam
  • 4,590
  • 10
  • 51
  • 84
3
votes
0 answers

EmitMapper + EF. Collection mapping issue

The source class: public class Page : EntityBase { public Page() { this.Articles = new List
(); } public virtual ICollection
Articles { get; set; } } public class Article : EntityBase { public…
2
votes
2 answers

EmitMapper and List

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
Salvatore Di Fazio
  • 705
  • 2
  • 7
  • 25
2
votes
0 answers

making emitmapper aware of inheretance

I'm trying to make emitmapper aware of hierarchies in my objects so it can select the most derived mapping for a class. Say that I have these classes public class Payment { } public class GuaranteePayment : Payment { } public class…
Ed Fox
  • 173
  • 1
  • 9
2
votes
2 answers

Automapper flattening multiple complex objects using custom mapping

So I have something besides the usual DTO to business mapper and I'm trying to map them with minimal amount of mapping code. Setup public class Target { public string propA { get; set; } public string propB { get; set; } public string…
Mrchief
  • 75,126
  • 20
  • 142
  • 189
2
votes
1 answer

Auto Mapping Internal Service References

I am creating a c# library that uses service references. I don't want the entire service to be accessible outside the library. So I first used AutoMapper to copy the service classes that I needed in to similar classes in my library. The second step…
pixelshaded
  • 313
  • 1
  • 2
  • 10
2
votes
0 answers

What is the EmitMapper equivalent for this AutoMapper configuration?

I have the following class and interface definitions, and would like to use EmitMapper instead of AutoMapper to map from class to interface. The current code works, but I'd like to use EmitMapper, yet have not figured out how to use it. public…
ARA
  • 53
  • 10
1
vote
2 answers

Emit Mapper Flattering and property name mismatch

How to map User class to UserModel class using Emit Mapper? public class User { public Guid Id { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public IList
petrov.alex
  • 1,089
  • 2
  • 12
  • 20
1
vote
0 answers

EmitMapper: Map array of derived classes

Let's assume that we have following class hierarchy class DtoBaseClass { public string BaseProperty {get; set;} } class A1 : DtoBaseClass { public string SomeProperty {get; set;} } class A2 : A { public string AnotherProperty…
John Smith
  • 103
  • 9
1
2