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
Hey :) I need to update our old razorEngine to a new one- while most of our templats run fine- we have a few template which are a bit more complex. when running template with the following code-
foreach (var field in Model.Fields.Where(f => !String.IsNullOrEmpty(f.Label) && f.Label.Equals("Some Text", StringComparison.OrdinalIgnoreCase)))
this worked fine with the old razor engine..
with the new one we get-the following error:
Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type.
so after pulling the enumarator logic and assign it outside (in our example lets say - var fields = Model.Fields...) the linq query we faced another error- 'System.Collections.Generic.List' does not contain a definition for 'FirstOrDefault' although we added @using System.Linq in the cshtml file and also while creating the template we inject System.Core, Version=4.0.0.0 assembly to make sure its not dll issues.. any idea if we are in the right direction or im missing something?
The text was updated successfully, but these errors were encountered:
Razor code: @{ var wallet = (IEnumerable<object>)(Model.Guest.UserWallets).Where(uw => uw.Wallet.IsActive).Single(); }
UserWallets is IList property.
Wallet.IsActive is boolean property.
Result:
CS1977 error - Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type.
@{ var wallet = (IEnumerable<object>)(Model.Guest.UserWallets).Single(); } works well.
@adoconnection Any ideas how to fix this / how to use lambda expressions?
Hey :) I need to update our old razorEngine to a new one- while most of our templats run fine- we have a few template which are a bit more complex. when running template with the following code-
this worked fine with the old razor engine..
with the new one we get-the following error:
so after pulling the enumarator logic and assign it outside (in our example lets say - var fields = Model.Fields...) the linq query we faced another error- 'System.Collections.Generic.List' does not contain a definition for 'FirstOrDefault' although we added
@using System.Linq in the cshtml file and also while creating the template we inject System.Core, Version=4.0.0.0 assembly to make sure its not dll issues.. any idea if we are in the right direction or im missing something?
The text was updated successfully, but these errors were encountered: