Problem with variable razor mvc

1

I have an EsperRule clas which has some properties, among them another EsperRule, my goal is to show all the data of the EsperRule and in case the other EsperRule is different from null, show the data of that and so on.

I did something like that but it does not work for me:

    <div class="col-md-offset-2 col-md-8">
            <table class="table" style="margin-bottom:0px">
                <tr><td><label>Campo</label></td><td>@Model.Field</td></tr>
                <tr><td><label>Operador lógico</label></td><td>@Model.LogicalOperator</td></tr>
                <tr><td><label>Umbral</label></td><td>@Model.Threshold</td></tr>
                <tr><td><label>Operador de unión</label></td><td>@Model.MergeOperator</td></tr>
            </table>
            @{EsperRule next = @Model.NextEsperRule; }
            @while (next != null)
            {
                <table class="table" style="margin-bottom:0px">
                    <tr><td><label>Campo</label></td><td>@next.Field</td></tr>
                    <tr><td><label>Operador lógico</label></td><td>@next.LogicalOperator</td></tr>
                    <tr><td><label>Umbral</label></td><td>@next.Threshold</td></tr>
                    <tr><td><label>Operador de unión</label></td><td>@next.MergeOperator</td></tr>
                </table>
                @next = @next.NextEsperRule;
            }
        </div>

I throw error in: @next = @next.NextEsperRule; How could I fix it?

    
asked by Juan Manuel 12.09.2017 в 15:18
source

1 answer

1

Simply delete the @ since you are inside a code of a block of instructions:

 @while (next != null)
{
    <table class="table" style="margin-bottom:0px">
                   //..
        </table>


   next = next.NextEsperRule; //eliminado las arrobas
 }
    
answered by 12.09.2017 / 15:30
source