2sic / 2sxc

DNN + 2sxc = #DNNCMS - This tool helps web designers and developers prepare great looking content in DNN (DotNetNuke). It's like mixing DNN with Umbraco and Drupal :)
http://2sxc.org
MIT License
145 stars 40 forks source link

Oqtane - Strong typed data in Html.Partial fails with error CS0246: The type or namespace name 'x' could not be found #3479

Closed enfJoao closed 1 month ago

enfJoao commented 1 month ago

I'm submitting a

[x] bug report [x] not sure

...about

[x] Razor templating [x] other / unknown

Current Behavior / Expected Behavior

This is a working code from a DNN app

Template A:

@inherits Custom.Hybrid.RazorTyped
@using AppCode
@using AppCode.Data

@Html.Partial("shared/_B.cshtml", new { Units = true, Years = true, Months = true })

Template B:

@inherits Custom.Hybrid.RazorTyped

@{
    var tUnits = App.Data.GetAll<zDepartments>()
 }

Results in CS0246: The type or namespace name 'zDepartments' could not be found

Adding

@using AppCode
@using AppCode.Data

to Template B results in CS0234: The type or namespace name 'Data' does not exist in the namespace 'AppCode'

Your environment

iJungleboy commented 1 month ago

This can't work. What should x be?

The correct setup would have a class like BlogPost in the AppCode.Data.

Then your file B would look like this:

@inherits Custom.Hybrid.RazorTyped
@using AppCode
@using AppCode.Data

@{
    var tB= App.Data.GetAll<BlogPost>();
 }
enfJoao commented 1 month ago

Sorry. When copying the code from my template I abbreviated too much. "x" is my datatype, so BlogPost for example.

Everything else is still valid. The class exists: image

enfJoao commented 1 month ago

Updated the original example.

enfJoao commented 1 month ago

To clarify:

Template A:

@inherits Custom.Hybrid.RazorTyped
@using AppCode
@using AppCode.Data

@Html.Partial("shared/_B.cshtml", new { Units = true, Years = true, Months = true })

Template B:

@inherits Custom.Hybrid.RazorTyped
@using AppCode
@using AppCode.Data

@{
    var tUnits = App.Data.GetAll<zDepartments>()
 }

Results in CS0234: The type or namespace name 'Data' does not exist in the namespace 'AppCode'

iJungleboy commented 1 month ago

Ok. I know you're coming from DNN - but above you wrote Oqtane.

We might have a bug in the AppCode in Oqtane, which @tvatavuk is looking into.

Can you confirm that ATM you're working in Oqtane?

enfJoao commented 1 month ago

Yes. I picked a DNN app and I'm trying to make it work in Oqtane. The current issue is in Oqtane.

tvatavuk commented 1 month ago

Thank you for reporting this issue! We identified that inconsistent path formatting was causing the problem, which has now been addressed by ensuring uniform path formatting for reliable comparisons. This fix will be included in the next release.