Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use Linq extension methods #523

Closed
Fosol opened this issue May 10, 2023 · 1 comment
Closed

Unable to use Linq extension methods #523

Fosol opened this issue May 10, 2023 · 1 comment

Comments

@Fosol
Copy link

Fosol commented May 10, 2023

Describe the bug
When I attempt to compile and render a string template it throws an error.

TNO.Services.Notification.NotificationManager: Error: Failed to handle message

Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'System.Collections.Generic.List<TNO.API.Areas.Services.Models.Content.ContentTonePoolModel>' does not contain a definition for 'FirstOrDefault'

To Reproduce
Create a template that includes a Linq statement and a FirstOrDefault() extension method call.

Expected behavior
I would expect as long as I have the @using System.Linq; statement in the template it should work correctly.

Information (please complete the following information):

  • OS: Any. I'm currently testing on Windows 11, but I also am getting the error in a docker container dotnet/skd:7.0.
  • Platform .NET 7
  • RazorLight version 2.3.1
  • Are you using the OFFICIAL RazorLight package? yes
  • vscode
@Fosol
Copy link
Author

Fosol commented May 11, 2023

To resolve this it requires setting the @model or providing the engine additional type information so that it can use extension methods.

@Fosol Fosol closed this as completed May 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant