首页 > 解决方案 > 获取整个列表中的第一行重复值视图中的计数列表

问题描述

MY SQl 输出 MY 输出视图两者不同

在 MS 服务器 Sql 中触发时的相同查询是正确的值。行数相同,但只有第一行在 LINQ 中重复......没有错误,不知道!

Table("SalarySlip")]
    public class Document
    {
        [Key]
        public string EmployeeID { get; set; }
        
        public string Basic { get; set; }
        public string Bonus { get; set; }
        public string Flexi { get; set; }
        public string HRA { get; set; }
        public string Month { get; set; }
        public string NetPay { get; set; }
        public string OtherDeduction { get; set; }
        public string PF { get; set; }
        public string Special { get; set; }
        public string TDS { get; set; }
        public string TotalDeduction { get; set; }
        public string TotalEarning { get; set; }
        public string Year { get; set; }
       }
        

public ActionResult EmpSalaryHistory(string EmployeeID )
{
    
    DatabaseContext _context = new DatabaseContext();
    var Userdata = _context.SalarySlip.Where(x => x.EmployeeID == EmployeeID).OrderByDescending(x => x.Month).ToList();


    if (Userdata.Count != 0)
    {
        TempData["data"] = EmployeeID;
        return View(Userdata);
    }
    else
    {
        TempData["data"] = EmployeeID;
        //return View();
        return RedirectToAction("Demo");
    }

}

标签: c#sqlasp.net-mvcentity-frameworklinq

解决方案


推荐阅读