Map DateTime as NHibernate.Type.TicksType
Hi
Is it possible to tell FNH that DateTime should always map to TicksType?
The following is not correct:
public class DateTimeConvention : IPropertyConvention, IPropertyConventionAcceptance
{
public void Apply(IPropertyInstance instance)
{
instance.CustomType(typeof(TicksType));
}
public void Accept(IAcceptanceCriteria<IPropertyInspector> criteria)
{
criteria.Expect(x => typeof (DateTime).IsAssignableFrom(x.Property.PropertyType));
}
}
Support Staff 2 Posted by James Gregory on 16 Oct, 2010 03:44 PM
Try:
criteria.Expect(x => x.Property.PropertyType == typeof(DateTime));
On Sat, Oct 16, 2010 at 1:50 PM, Jacob <
***@tenderapp.com<tender%***@tenderapp.com>
> wrote:
3 Posted by Jacob on 16 Oct, 2010 09:45 PM
I get this when trying:
[MappingException: Could not instantiate IType TicksType: System.MissingMethodException: No parameterless constructor defined for this object. at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache) at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache) at System.Activator.CreateInstance(Type type, Boolean nonPublic) at System.Activator.CreateInstance(Type type) at NHibernate.Bytecode.ActivatorObjectsFactory.CreateInstance(Type type) in d:\CSharp\NH\nhibernate\src\NHibernate\Bytecode\ActivatorObjectsFactory.cs:line 9 at NHibernate.Type.TypeFactory.HeuristicType(String typeName, IDictionary`2 parameters) in d:\CSharp\NH\nhibernate\src\NHibernate\Type\TypeFactory.cs:line 479]
4 Posted by Jacob on 16 Oct, 2010 09:52 PM
It works.
instance.CustomType(typeof(TicksType));
should be:
instance.CustomType("Ticks");