我一直在尝试列出数据库中的所有用户,但我很难。我是 MVC3 的新手,请帮忙。:)
这是我的用户列表
using System;
using System.Data.Entity;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using MVCDemo.Models.DB;
using MVCDemo.Models.ViewModel;
namespace MVCDemo.Models.ViewModel
{
public class UserList
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string ContactNumber { get; set; }
public string Address { get; set; }
public string Email { get; set; }
public string Username { get; set; }
public string Password { get; set; }
}
public class Users
{
private DeveloperReportEntities dre = new DeveloperReportEntities();
public UserList _userList = new UserList();
public Users()
{
DB.Users_Tbl userTBL = new DB.Users_Tbl();
_userList.FirstName = userTBL.FirstName;
_userList.LastName = userTBL.LastName;
_userList.Email = userTBL.Email;
_userList.Address = userTBL.Address;
_userList.ContactNumber = userTBL.ContactNo;
_userList.Username = userTBL.Username;
_userList.Password = userTBL.Password;
}
}
}
应该通过这里控制:AdminController
public class AdminController : Controller
{
//
// GET: /Admin/
public ActionResult AdminHomePage()
{
return View();
}
public ActionResult ViewAll()
{
return View();
}
}
在我的解决方案资源管理器中,模型文件夹中有一个 samplemodel.edmx