我遇到了Json和Lists的问题
我试图返回一个聊天实体类列表,但当我尝试返回它时编译器发出呜呜声.我也尝试返回IEnumerable <>,但同样的错误来了
我能做什么 ?
这是我的函数返回项目,
public List<Chat> GetNewChatPosts()
{
var userID = U_rep.GetUserID(User.Identity.Name);
var list = G_rep.GetNewestChat(0, userID);
return Json(list);
}
Run Code Online (Sandbox Code Playgroud)
这是Get Newest Chat功能
public List<Chat> GetNewestChat(int gameID, int userID)
{
var pos1 = (from p in n_db.ChatPos
where p.userID == userID && gameID == p.gameID
select p).SingleOrDefault();
int pos;
if (pos1 == null)
{
pos = 0;
ChatPo n = new ChatPo();
n.gameID = gameID;
n.userID = userID;
n.chatID = pos;
n_db.ChatPos.InsertOnSubmit(n);
n_db.SubmitChanges();
}
else
{
pos = …Run Code Online (Sandbox Code Playgroud)