Skip to content

Instantly share code, notes, and snippets.

@mhinze
Created July 3, 2009 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhinze/140166 to your computer and use it in GitHub Desktop.
Save mhinze/140166 to your computer and use it in GitHub Desktop.
private void MapAllPersistentObjects()
{
var openType = typeof(IdToEntityConverter<>);
var guidType = typeof(Guid);
var allPersistentObjects =
from t in typeof(Customer).Assembly.GetTypes()
where typeof(Entity).IsAssignableFrom(t)
let converterType = openType.MakeGenericType(t)
select new {EntityType = t, ConverterType = converterType};
allPersistentObjects.ForEach(t => CreateMap(guidType, t.EntityType).ConvertUsing(t.ConverterType));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment