With a strategically placed Debug write, the component low and high values 
are properly being set, but the failure is happening after the owner 
component instance has been set, as far as I can determine.

NullSafeGet: fields: 18, names: [lowvalueduetime7_10_0_], owner class: 
'WhalleyBotEnhanced.Tracks.TrackMeetLane'.
NullSafeGet: fields: 18, names: [lowvalueperiod8_10_0_], owner class: 
'WhalleyBotEnhanced.Tracks.TrackMeetLane'.
NullSafeGet: fields: 18, names: [lowvalueduration9_10_0_], owner class: 
'WhalleyBotEnhanced.Tracks.TrackMeetLane'.
NullSafeGet: fields: 18, names: [highvalueduetime11_10_0_], owner class: 
'WhalleyBotEnhanced.Tracks.TrackMeetLane'.
NullSafeGet: fields: 18, names: [highvalueperiod12_10_0_], owner class: 
'WhalleyBotEnhanced.Tracks.TrackMeetLane'.
NullSafeGet: fields: 18, names: [highvalueduration13_10_0_], owner class: 
'WhalleyBotEnhanced.Tracks.TrackMeetLane'.

Which there is some property setter logic going on there, but I wonder if 
that should not be a simple receiver of the NH negotiated component 
instance. One example:

public virtual SchedulablePlayerComponentData HighValue
{
    get => _highValue;
    set
    {
        var highValue = _highValue;

        if (SetProperty(ref highValue, value ?? new()) && 
!ReferenceEquals(highValue, _highValue))
        {
            _highValue.AcceptValue(highValue);
        }
    }
}

So instead we just do: set => SetProperty(ref _highValue, value), and if we 
need to connect any business logic after that, we do that, but let NH 
handle the component property itself.

Not dissimilar in approach from IList<T> collections, adding model or view 
model observability, ObservableCollection<T> around those source 
collections, for proper parent-child referencing.

Thoughts?
On Friday, June 27, 2025 at 12:04:25 PM UTC-4 Michael W Powell wrote:

> Hello,
>
> I have the dialect arranging a map between TimeSpan and NodaTime.Duration. 
> I step through several such user type conversions from and to, assembled 
> and disassembled, so I know that at least it should be able to handle the 
> use case.
>
> However, still receiving an exception, not sure quite as to why, maybe 
> something TimeSpan? Nullable is appearing in the ADO recordset somehow, I'm 
> not sure yet.
>
> And sorry for the mess here, the excptions, messages, and the query... The 
> data is all there as expected, and have traced up the callstack, up to and 
> including the repository pattern IQueryable query provider, everything else 
> being equal, the values SHOULD be landing in the mapped property(ies) 
> correctly.
>
> Trouble is in an exception like this, I do not know per se "which" 
> properties are failing. I'll look at possibly doing some Debug writes at 
> strategic IUserType moments when those details, alias, etc, are better 
> known. Although I'm not sure exactly that will tell me property names, more 
> like the query alias names, which is also not especially helpful.
>
> BTW, if it matters, the columns in question, are properly mapped in the 
> context of a fluent Component. This is intentionally properly the case. 
> I'll also have to review the component code, because I'm not hundred 
> percent certain those properties are not internally or privately set, with 
> their values either calculated or ctor provided.
>
> Thanks!
>
> NHibernate.Exceptions.GenericADOException: 'could not initialize a 
> collection: 
> [WhalleyBotEnhanced.Tracks.TrackMeetEvent.Lanes#c0832da0-d2f9-412c-8364-059f7ed205b5][SQL:
>  
> SELECT lanes0_.TrackMeetEventId as trackmeeteventid3_10_1_, lanes0_.Id as 
> id1_10_1_, lanes0_.Id as id1_10_0_, lanes0_.Enabled as enabled2_10_0_, 
> lanes0_.TrackMeetEventId as trackmeeteventid3_10_0_, lanes0_.Name as 
> name4_10_0_, lanes0_.Color as color5_10_0_, lanes0_.lowValuePlayerCount as 
> lowvalueplayercount6_10_0_, lanes0_.lowValueDueTime as 
> lowvalueduetime7_10_0_, lanes0_.lowValuePeriod as lowvalueperiod8_10_0_, 
> lanes0_.lowValueDuration as lowvalueduration9_10_0_, 
> lanes0_.highValuePlayerCount as highvalueplayercount10_10_0_, 
> lanes0_.highValueDueTime as highvalueduetime11_10_0_, 
> lanes0_.highValuePeriod as highvalueperiod12_10_0_, 
> lanes0_.highValueDuration as highvalueduration13_10_0_, 
> lanes0_.packCategoriesJson as packcategoriesjson14_10_0_, 
> lanes0_.packIdsJson as packidsjson15_10_0_, lanes0_.positionsJson as 
> positionsjson16_10_0_ FROM public.efcore_wbe_trackmeetlane lanes0_ WHERE 
> lanes0_.TrackMeetEventId=?]'
>
> - $exception {"could not initialize a collection: 
> [WhalleyBotEnhanced.Tracks.TrackMeetEvent.Lanes#c0832da0-d2f9-412c-8364-059f7ed205b5][SQL:
>  
> SELECT lanes0_.TrackMeetEventId as trackmeeteventid3_10_1_, lanes0_.Id as 
> id1_10_1_, lanes0_.Id as id1_10_0_, lanes0_.Enabled as enabled2_10_0_, 
> lanes0_.TrackMeetEventId as trackmeeteventid3_10_0_, lanes0_.Name as 
> name4_10_0_, lanes0_.Color as color5_10_0_, lanes0_.lowValuePlayerCount as 
> lowvalueplayercount6_10_0_, lanes0_.lowValueDueTime as 
> lowvalueduetime7_10_0_, lanes0_.lowValuePeriod as lowvalueperiod8_10_0_, 
> lanes0_.lowValueDuration as lowvalueduration9_10_0_, 
> lanes0_.highValuePlayerCount as highvalueplayercount10_10_0_, 
> lanes0_.highValueDueTime as highvalueduetime11_10_0_, 
> lanes0_.highValuePeriod as highvalueperiod12_10_0_, 
> lanes0_.highValueDuration as highvalueduration13_10_0_, 
> lanes0_.packCategoriesJson as packcategoriesjson14_10_0_, 
> lanes0_.packIdsJson as packidsjson15_10_0_, lanes0_.positionsJson as 
> positionsjson16_10_0_ FROM public.efcore_wbe_trackmeetlane lanes0_ WHERE 
> lane..."} NHibernate.Exceptions.GenericADOException
>
> + InnerException {"Unable to cast object of type 'System.TimeSpan' to 
> type 'NodaTime.Duration'."} System.Exception {System.InvalidCastException}
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/fluent-nhibernate/f6ad9510-cd56-4a90-be8c-7e00e3d8db4cn%40googlegroups.com.

Reply via email to