I am working on an ASP.NET MVC application using NHibernate as the ORM. I have two domain objects:
public class Contact
{
public int ID { get; set }
public string Name { get;set; }
public IList<ContactNumber> ContactNumbers { get; set; }
}
public class ContactNumber
{
p...
I got this test:
[Fact]
public void EverythingIsMappedJustFine(){
new AutoMapperTask().Execute();
Mapper.AssertConfigurationIsValid();
}
It throws a bit strange exception:
Test 'Unit.Web.Bootstrap.AutoMapperFacts.EverythingIsMappedJustFine' failed:
System.InvalidOperationException : No coercion operator is defined
betwee...
I'm considering to use AutoMapper in the upcoming project and trying to find possible "bottlenecks". At the moment the most complex case i can imagine is the following:
A domain class which is represented by 3 (for example) tables in the database (my data access layer is LINQ to SQL). To build an instance of the class i need to perform 3...
I have an MVC2 n-tier application (DAL, Domain, Service, MVC web) using a DDD approach (Domain Driven Design), having a Domain Model with repositories. My service layer uses a Request/Response pattern, in which the Request and Response objects contain DTO's (Data Transfer Objects) to marshal data from one layer to the next, and the mapp...
Hi,
when I'm using this mapping
Mapper.CreateMap<DataSourceConfigurationContract, DataSourceConfigurationContract>().ForMember(x => (object)x.DatabaseTypeException, opt => opt.Ignore())
.ForMember(x => (object)x.DatabaseType, opt =...
I'm using Entity Framework behind a set of repositories. The repositories use DTOs instead of the entity objects generated by the Entity Framework. I'm using AutoMapper to convert them back and forth.
I'm having trouble figuring out how to do the following:
Method definition:
public IEnumerable<DTO.User> Get(Func<DTO.User, bool> where...
In my MVC 2 application I have a typical method that calls a web service, builds a JSON data object and returns it to the view.
Everything works fine, but I was wondering if there is a way to do the mapping with Automapper so I can remove the ugly code from my controller. Thanks in advance
Here is my Action method
public virtual Actio...
How can I override the type converter being used by AutoMapper for a given property?
For example, if I have:
public class Foo
{
public string Name { get; set; }
}
public class Bar
{
public string Name { get; set; }
}
Now I simply want to map Foo.Name to Bar.Name but using a specified type converter. I see how I can do it usi...
AutoMapper for .Net lets you map from one type to another. Its most basic function is to create one type of class from another type of class by copying property values from type A that exist in type B (have matching names and types).
Example:
public class ClassA {
public string StringProp { get; set; }
public int IntProp { get...
Hey all,
My question might be silly, but I'm pretty sure I miss a very important part of the issue. I have to do some object to object mapping (between domain classes used in C# project and classes which are sent to flash clients).
My first choice was Automapper. But Ive had some issues with it (nested properties, not paramterless cons...
I.e. transferring the state from one object to another object, which shares some (but not all) of the first object's members.
I'm not applying this question to any real-life problem yet, but I guess I'm asking it to get a feel for the differences between the problem-solving approach in LISP as opposed to object-oriented languages like C...
I just threw together a custom AutoMapper ValueResolver to try to map a condition from my domain object to a boolean property on an MVC view model, and it's so simple that I have a feeling there has to be a built-in way to do what I'm trying to do without a custom resolver.
The logic that I'm trying to implement is that if "MyDomainObje...
What would the C# code be to create a (service) method to return an object (ViewModel for DDL) using AutoMapper and provide the two field names as parameters?
DDL is for a Drop Down List:
public class DDLitems {
public string text {get;set;}
public string value {get;set}
}
My horrible pseudo C# code idea: (yea no idea how to ...
I have this C# code that works just fine, which grabs any two fields and puts them in a list for a Drop Down List:
var myDDL = GetDDLValues<Product>( myContact, "contactid", "companyname");
I would like it to take the two string parameters in something other than strings. This would be really nice to do:
GetDDLValues<Product>( myCon...
Suppose I have a destination class and a source class that are mostly the same. Almost all of the properties map automatically using automapper.
Say that of the 30 properties on these classes, two don't have a direct corelation in any way that automapper can automatically figureout.
Is there a way to tell automapper to connect two pro...
I am trying to decide if I want to pursue Automapper as a technology to use at my company. Before I dig in, I have a question that I want to be sure is doable with automapper.
Say I have a property in my destination class that I don't want to fill with automapper. Is there a way to tell automapper to ignore the property and not fail w...
I have a Linq to Sql source being mapped to a DTO.
The src contains a property which does not exist in the DTO. I.e. src.State exists but dest.State does not exist.
This causes the Mapping Configuration to throw a ConfigurationException.
I don't want to add the property to the DTO (e.g. dest.State) to make it work and the .ForMember...