我的班级显示编译错误:
namespace Zone.Models
{
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Web;
using System.Web.Mvc;
using Zone.Models;
public class MyViewModel
{
public MyInfo Info { get; set; }
public PageNumberResults { get; set; }
}
}
得到的错误如下:
Error 1 Invalid token '{' in class, struct, or interface member declaration
Error 2 Invalid token ';' in class, struct, or interface member declaration
Error 3 Invalid token ';' in class, struct, or interface member declaration
Error 4 Type or namespace definition, or end-of-file expected
我的控制器显示了游戏是如何通过界面输入到数据库中的:
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using PagedList;
using System.Web.Mvc;
using Zone.Models;
namespace Zone.Controllers
{
public class GameController : Controller
{
private mydbEntities db = new mydbEntities();
public ViewResult Index(string Ordering, int? CounterForPage)
{
var FullDatabaseItem = from b in db.tblGames
select b;
var Info = db.tblGames.Include(x => x.tblConsole).Where(UserInfo => UserInfo.UserName.Equals(User.Identity.Name)).ToList();
switch (Ordering)
{
case "HeadlineName":
FullDatabaseItem = FullDatabaseItem.OrderBy(b => b.GameName);
break;
case "DatePosted":
FullDatabaseItem = FullDatabaseItem.OrderBy(b => b.ReleaseYear);
break;
case "DiscriptionDate":
FullDatabaseItem = FullDatabaseItem.OrderBy(b => b.ReleaseYear);
break;
default:
FullDatabaseItem = FullDatabaseItem.OrderByDescending(b => b.ReleaseYear);
break;
}
int pageSize = 3;
int pageNumber = (CounterForPage ?? 1);
var PageNumberResults = FullDatabaseItem.ToPagedList(pageNumber, pageSize);
if (PageNumberResults.Any())
{
return View(new MyViewModel()
{
Info = info,
PageNumberResults = FullDatabaseItem.Count()
});
}
return View("ErrorView");
}
}
}
任何帮助,将不胜感激