4.3 Release - Linq Bindings FirstOrDefault 'TypeError'

Hi team,
Since I updated my DotVVM packages to the latest 4.3.0 version along with DotVVM.Controls.Bootstrap4 to 4.3.0, I’m getting errors as shown in the console log below.

It happens when using a binding such as Visible="{value: !MyList.FirstOrDefault(x => x.ID == SelectedID).SomeProperty}". This used to work fine before the update, is there something I need to change or update in my code?

I don’t see any compile time issues or any concerns from the ’ Compilation status page’. Any assistance would be greatly appreciated!

VM391:3 
Uncaught TypeError: MyList(...)?.find(...)?.SomeProperty is not a function
    at visible (eval at createBindingsStringEvaluator (knockout:3301:16), <anonymous>:3:130)
    at evaluateValueAccessor (knockout:3574:16)
    at knockout:3751:32
    at update (knockout:5628:47)
    at ko.dependentObservable.disposeWhenNodeIsRemoved (knockout:3825:33)
    at Function.evaluateImmediate_CallReadThenEndDependencyDetection (knockout:2411:103)
    at Function.evaluateImmediate_CallReadWithDependencyDetection (knockout:2368:29)
    at Function.evaluateImmediate (knockout:2333:28)
    at Function.evaluatePossiblyAsync (knockout:2298:32)
    at Function.notifySubscribers (knockout:1456:38)
visible	@	VM391:3
evaluateValueAccessor	@	knockout:3574
(anonymous)	@	knockout:3751
update	@	knockout:5628
ko.dependentObservable.disposeWhenNodeIsRemoved	@	knockout:3825
evaluateImmediate_CallReadThenEndDependencyDetection	@	knockout:2411
evaluateImmediate_CallReadWithDependencyDetection	@	knockout:2368
evaluateImmediate	@	knockout:2333
evaluatePossiblyAsync	@	knockout:2298
notifySubscribers	@	knockout:1456
valueHasMutated	@	knockout:1709
observable	@	knockout:1672
writeValueToProperty	@	knockout:2984
(anonymous)	@	knockout:5520
run	@	knockout:80
valueUpdateHandler	@	knockout:5515
(anonymous)	@	knockout:5607
dispatch	@	jquery-3.6.1.min.js:2
y.handle	@	jquery-3.6.1.min.js:2

I should just clarify that “SomeProperty” is a boolean type. It also fails with a similar message if I just have literally TheValue = {{value: !MyList.FirstOrDefault(x => x.ID == SelectedID).SomeProperty}} in my dothtml file, or if I explicitly compare to true/false the expression like Visible="{value: !MyList.FirstOrDefault(x => x.ID == SelectedID).SomeProperty == false}".

Hi! Thank you for the bug report, it is indeed a regression in the 4.3 release. I discovered there were related issues in more complex cases, such as .Select(...).ToArray()[0], so it took me bit longer to fix. The fixes are coming either in Fix ko.observable handling in Linq translations by exyi · Pull Request #1870 · riganti/dotvvm · GitHub, or Hot fix for missing ko.unwrap in Linq Last,First,ElementAt translations by exyi · Pull Request #1871 · riganti/dotvvm · GitHub.

If you need a workaround, using .Select(a => a) before the FirstOrDefault will exploit the second bug to mitigate the first one and should run :sweat_smile:

Ok look forward to the next update with the fix, thanks! For now, I’ve just downgraded to 4.2 and that’s working all fine.

Hi! The 4.3.2 version should have this fixed.