automapper

Using AutoMapper to map from XElement to a strongly typed class ?

Can I use AutoMapper to map from data in an XElement to my own type ? How ? ...

Can automapper map a foreign key to an object using a repository?

I'm trying out Entity Framework Code first CTP4. Suppose I have: public class Parent { public int Id { get; set; } public string Name { get; set; } } public class Child { public int Id { get; set; } public string Name { get; set; } public Parent Mother { get; set; } } public class TestContext : DbContext { pub...

NHibernate, AutoMapper and ASP.NET MVC

I'm wondering about a "best practice" using NHibernate, AutoMapper and ASP.NET MVC. Currently, i'm using : class Entity { public int Id { get; set; } public string Label { get; set; } } class Model { public int Id { get; set; } public string Label { get; set; } } Entity and model are mapped like this : Mapper.CreateM...

How to copy data from dataset to a type dataset using automapper?

Hi, i am trying to copy data from a standard Dataset to a Type Dataset (XSD) of same table structure. i want to use Automapper to do that one. So how can i do that using automapper? ...

Automapper with a base class enumeration property

Is there any way to get this to work? Here's a simplified/contrived illustration of my issue (Pardon my wordy VB): Domain Model Classes Public Class Car Public Property Id As Integer Public Property Seats As IEnumerable(Of Seat) End Class Public MustInherit Class Seat End Class Public Class StandardSeat Inherits Seat Pu...

Html.DropDownList AutoMapper problem

I am receiving this error: The ViewData item that has the key 'DepartmentId' is of type 'System.Int32' but must be of type 'IEnumerable'. with the following set up. I am not sure how to resolve it. The error is happening in the Model View code. This line: public void MapTo(Person domainModel). I am using AutoMapper to map ViewM...

Mapping to a destination that doesn't exist in the source based on propery name with Automapper

If I have a nested source and destination like this: public class UserInformationViewModel { public string UserName { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public string Organization { get; set; } public string EmailAddress { get; set; } public PhysicalAddressViewM...

Is it possible to map a IDataReader to a nested DTO using automapper?

I was hoping that I could map a flat datareader into a nested DTO. Running the following code the name is null. Am I doing something wrong or is this just not possible? class Program { public class Person { public int id { get; set; } public Name name { get; set; } } public class Name { ...

Is is feasible to try to convert expression trees between business and data domains?

I have a repository layer that deals with LINQ to SQL autogenerated entities. These eventually get mapped into domain-friendly types on the surface. I'd now like to provide some more sophisticated querying capabilities for the client code, and that client code knows only about the domain object types. I'd like to implement this with t...

Copying Models Between Layers

When traversing layers it is very tedious to perform right->left assignments as a way to populate the models. For example: employeeViewModel.FirstName = employeeModel.FirstName; employeeViewModel.LastName = employeeModel.LastName; ... So, we can build a ModelCopier which uses reflection to copy models: var employeeViewModel = ModelC...

In AutoMapper, is it possible to determine what the destination property name would be for a particular source property.

Note: the question relates to the mapping meta-data, not the mapped values. i.e. what is the NAME of the target mapped property, not the mapped value. Background: I'm using MVC 2 with automapper to map between domain entities and view models. I have some validation rules at the domain level which are defined in the domain model, and s...

Does Automapper supports Linq to entities (V1.1)

Hi Experts, Does AutoMapper supports linq to entities (framework 1.1). Is there any sample project available. Also using linq to SQL when I try convert from POCO to entity object, it fails saying AutomapperTest.Test.Account Help will be appreciated. Regards Parminder ...

Automapping Lists

I'm starting to learn AutoMapper and coming up against a couple of minor problems. Essentially I'm getting null reference exceptions when trying to bind to ILists produced by AutoMapper. My boot strapping method looks like this: Mapper.CreateMap<Claimant, ClaimantViewModel>() .ForMember( vm => v...

Injecting AutoMapper dependencies using Ninject

I am having trouble injecting AutoMapper into an ASP.NET MVC 2 application using Ninject. I used Jimmy Bogard's post on AutoMapper and StructureMap type Configuration as a guide. public class AutoMapperModule : NinjectModule { public override void Load() { Bind<ITypeMapFactory>().To<TypeMapFactory>(); Bind<Config...

Automapper: Type conversion/formatting

Using AutoMapper, is it possible to do a type conversion and selectively format the destination value based on a ForMember expression? public class TestConverter : ITypeConverter<string, IHtmlString> { public IHtmlString Convert(ResolutionContext context) { return new MvcHtmlString(context.SourceValue.ToString()); ...

Polymorphism with AutoMapper

I have these business classes: class BaseNode { public string name; } class CompositeNode : BaseNode { public List<BaseNode> childs = new List<BaseNode>(); } And this flat dto: class NodeDto { public string name; public List<NodeDto> childs; } (note how all der...

AutoMapper / Castle - Inheritance security rules violated while overriding member

I am getting the following exception when calling any of my Mapper.Map methods. Inheritance security rules violated while overriding member: 'Castle.Core.Logging.LevelFilteredLogger.InitializeLifetimeService()'. Security accessibility of the overriding method must match the security accessibility of the method being overriden. I am us...

Complex collections with Automapper

Here is what I have where I hope someone can help us out: class `Source` { string name { get; set; } Inner { get; set; } } class `Inner` { Col A { get; set; } Col B { get; set; } } class `Col` : IList<`ClassX`>, IEnunmerable<`ClassX`> I need to map class Source to a destination type which has: cla...

Issue with AutoMapper and mapping IEnumerable collections

Here is the code for the mapper: public IEnumerable<GetQuestionsContract> Map(IEnumerable<XmlNode> nodes, XmlNamespaceManager namespaceManager) { Mapper.CreateMap<XmlNode, GetQuestionsContract>() .ForMember( dest => dest.Id, options => options.ResolveUsing<XmlNodeR...

Adding custom convention rule to Automapper

I have been using Automapper to map from my entities to my ViewModels successfully. I was getting tired of having to mark my Add and Edit Models with the [Required] attribute so I decided to add a custom Metadata Provider that would take any property ending with "X" and make it required. Needless to say now the conventions in Automapper ...