I am trying to format the output of a query in a WebMatrix 2 CSHTML file. This is the code I am using:
@foreach(var row in db.Query(selectQueryString))
{
@row.Firstname; + " " + @row.lastname; + " " + @row.Entry;
}
I am getting this error:
"CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement"
The first issue is that the semicolons could be confusing to Razor, and they are only confusing matters. So change the line in the brackets to
<text>@row.Firstname @row.lastname @row.Entry</text>
And see if that works. The < text > tags tells Razor to output this directly as HTML and not use it as code. You don't need the + " " because once you're putting out HTML, the spaces come automatically.