Skip to content

Instantly share code, notes, and snippets.

@tswann
Created January 27, 2014 14:21
Show Gist options
  • Save tswann/8649357 to your computer and use it in GitHub Desktop.
Save tswann/8649357 to your computer and use it in GitHub Desktop.
Example of using AutoMapper to convert a EF generated POCO to a CRM entity.
using AutoMapper;
using Microsoft.Xrm.Sdk;
public class AutoMapperProfile : Profile
{
protected override void Configure()
{
this.RecognizePrefixes("new_");
this.CreateMap<stg_Contact, Contact)
.ForMember(dest => dest.ParentCustomerId, o => o.MapFrom(src => new EntityReference(Account.EntityLogicalName, src.ParentCustomerId)));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment