That doesn't work with the new convention overhaul (the methods are
all changed). I was able to do it like this:
public class CustomClassConvention : IClassConvention
{
public bool Accept(IClassMap target)
{
return true;
}
public void Apply(IClassMap target)
{
var propertiesToIgnore = target.Parts.OfType<IProperty>()
.Where(p => p.Property.GetCustomAttributes(typeof
(AutoMapIgnoreAttribute), true).Length > 0).ToList();
foreach (var property in propertiesToIgnore)
((IList<IMappingPart>) target.Parts).Remove(property);
if (target.EntityType.GetCustomAttributes(typeof
(ReadOnlyAttribute), true).Length > 0)
target.ReadOnly();
}
}
public class AutoMapIgnoreAttribute : Attribute
{
}
You'll see some stuff in here that looks like a hack because it is a
hack. :) What would make this easier to do is if we had a RemovePart
() method on the ClasslikeMapBase class, then I wouldn't have to cast
an IEnumerable<T> to an IList<T>. :)
Patch for said change is here:
http://jonkruger.com/ClasslikeMapBase.RemovePart.patch
Jon