I have this working code:
@{
var ekgList = AsList(App.Data["Ekgs"]);
foreach(var ekg in ekgList) {
<div>
@foreach (var entitiesFromSinusDataType in ekg.Sinus) {
if(entitiesFromSinusDataType.EntityId == Content.EntityId) {
<a>@ekg.ShortName</a>
}
}
</div>
}
}
For what I can understand:
There should be an easy way to remove the second loop and the "if", by placing a where clause in the first loop. I'm trying this step by step, but as soon as I try this:
@{
var ekgList = AsList(App.Data["Ekgs"]);
foreach(var ekg in ekgList) {
<div>
@foreach (var entitiesFromSinusDataType in ekg.Sinus.Where(i => i.EntityId == Content.EntityId)) {
<a>@ekg.ShortName</a>
}
</div>
}
}
I get this error:
CS1977: Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type
This seems to be caused by using dynamic types.
Is there some way to cast the lists into a non dynamic version of them?
Try to cast the ekg.Sinus
to ((IEnumerable<dynamic>)ekg.Sinus)
:
((IEnumerable<dynamic>)ekg.Sinus).Where(i => i.EntityId == Content.EntityId)
I hope this will help you out.