歧义错误

本文关键字:错误 歧义 | 更新日期: 2023-09-27 18:32:01

这是我的代码

 HotelMGT _DB = new HotelMGT();
    public virtual ActionResult Index()
    {
        ViewBag.TypeID = new string[] { "Assets", "Liabilities", "Income","Expenses" };
        var model = from r in _DB.AccountHead
                    orderby r.AccountHeadID ascending
                    //where r.AccountTypeID == AccountTypeID || (AccountTypeID==null)
                    select r; //_DB.AccountType;
        return View(model );
    }

我收到以下错误。

 Ambiguity between 'MyHotel.Models.HotelMGT.AccountHead' and   
 'MyHotel.Models.HotelMGT.AccountHead'

识别与 C# 或 MVC 相关的错误,我该如何解决这个问题?欢迎所有建议。

问候。

歧义错误

您比较相同的值,因此请指定从中获取数据的表。

错误实际上是说你比较一个鸡蛋和一个鸡蛋,但你只有 1 个鸡蛋,我们需要另一个鸡蛋。