You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*****Error*****
NHibernate.Exceptions.GenericADOException: System.NullReferenceException: The object reference is not set to an instance of the object。
in Abp.NHibernate.AbpNHibernateInterceptor.NormalizeDateTimePropertiesForComponentType(Object componentObject, IType type)
in Abp.NHibernate.AbpNHibernateInterceptor.NormalizeDateTimePropertiesForEntity(Object[] state, IList`1 types)
in Abp.NHibernate.AbpNHibernateInterceptor.OnLoad(Object entity, Object id, Object[] state, String[] propertyNames, IType[] types)
in NHibernate.Event.Default.DefaultPreLoadEventListener.OnPreLoad(PreLoadEvent event)
in NHibernate.Engine.TwoPhaseLoad.InitializeEntity(Object entity, Boolean readOnly, ISessionImplementor session, PreLoadEvent preLoadEvent, PostLoadEvent postLoadEvent)
Steps needed to reproduce the problem.
Stack Overflow
Add ValueObject like code
public class TimeRange : ValueObject<TimeRange>
{
public DateTime? Start { get; set; }
public DateTime? End { get; set; }
}
Add Entity
public class BreakScheduleTime : EntityBase
{
public BreakScheduleTime()
{
this.TimeRange = new TimeRange();
}
/// <summary>
/// 休息时间范围
/// </summary>
public virtual TimeRange TimeRange { get; set; }
}
My Code like up,when I save BreakScheduleTime .TimeRange all Start and End null , it can be saved.
But when I get BreakScheduleTime , it's error , error message is 'System.NullReferenceException: The object reference is not set to an instance of the object'.
If one of start and end is not null , get BreakScheduleTime is ok .
I look at the abp source code.
code file AbpNHibernateInterceptor.cs, the 226 row, I think must guard the componentObject is not null, so I change this code like
private static void NormalizeDateTimePropertiesForComponentType(object componentObject, IType type)
{
if(componentObject == null)
{
return ;
}
var componentType = type as ComponentType;
...
}
I use up code is ok , so I think the code in AbpNHibernateInterceptor.cs has a bug.
Am I right ?
The text was updated successfully, but these errors were encountered:
hikalkan
changed the title
AbpNHibernateInterceptor bug : System.NullReferenceException
NHibernate NullReferenceException for null value types in entities
Nov 15, 2017
Github Issues
Stack Overflow
My Code like up,when I save BreakScheduleTime .TimeRange all Start and End null , it can be saved.
But when I get BreakScheduleTime , it's error , error message is 'System.NullReferenceException: The object reference is not set to an instance of the object'.
If one of start and end is not null , get BreakScheduleTime is ok .
I look at the abp source code.
code file
AbpNHibernateInterceptor.cs
, the 226 row, I think must guard thecomponentObject
is not null, so I change this code likeI use up code is ok , so I think the code in
AbpNHibernateInterceptor.cs
has a bug.Am I right ?
The text was updated successfully, but these errors were encountered: