I'm trying to use a 2sxc view to create some statistics with linq. However I can't seem to be able to call any c# var. Here's an example:
@{
if (@Request.QueryString["ano"] == "" || @Request.QueryString["ano"] == null) {
<p>ano not set, using current year (@DateTime.Now.Year)</p>
var year = @DateTime.Now.Year;
} else {
<p>ano set (@Request.QueryString["ano"])</p>
var year = @Request.QueryString["ano"];
}
var items = AsDynamic(App.Data["entity"]);
items = items.Where(p => Convert.ToDateTime(p.data_a).Year == year);
}
This results in
error CS0103: The name 'year' does not exist in the current context
Am I doing something really stupid again?