Linq语句从db中选择行并在MVC视图中显示为列表

时间:2013-07-12 18:52:54

标签: asp.net-mvc linq

我需要从状态为关闭的表中选择所有行,然后我需要在asp.net mvc视图的列表中显示结果。

我应该在cshtml的第一行放置什么?

 @model HelpDesk.Domain.Entities.Ticket
    @{
    ViewBag.Title = "Help Desk | Admin Console";
    Layout = "~/Views/Shared/_Layout.cshtml";
    ViewBag.selectedSub = 0;
    }

这里怎么样。

@using (Html.BeginForm())
{   
}

这是方法。

public Tickets GetTicketByStatus(string status)
    {
        return context.dbentity.Where()........
    }

这是模型

public class Ticket
    {
        public int CaseID { get; set; }
        public string Title { get; set; }
        [Required]
        public string UFirstName { get; set; }
        [Required]
        public string ULastName { get; set; }
        //public string UDisplayName { get; set; }
        [Required]
        public string UDep_Location { get; set; }
        [Required]
        public string UEmailAddress { get; set; }
        //public string UComputerName { get; set; }
        //public string UIPAddress { get; set; }
        [Required]
        public string UPhoneNumber { get; set; }
        [Required]
        public string Priority { get; set; }
        [Required]
        public string ProbCat { get; set; }
        //public string IniDateTime { get; set; }
        //public string UpdateProbDetails { get; set; }
        //public string UpdatedBy { get; set; }
        public string InitiatedBy_tech { get; set; }
        public string AssignedBy { get; set; }
        [Required]
        public string TechAssigned { get; set; }
        [Required]
        [DataType(DataType.MultilineText)]
        public string ProbDetails { get; set; }
        [Required]
        public string TicketStatus { get; set; }
        public string TicketSource { get; set; }
    }

0 个答案:

没有答案