'object' does not contain a definition for 'X'

前端 未结 4 1939
旧时难觅i
旧时难觅i 2020-11-29 06:35

I had this problem once before and didn\'t resolve it. I have a list (generated in an MVC3 controller):

ViewBag.Languages = db.Languages
    .Select(x =>         


        
4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-29 06:49

    This was driving me spare until I checked my code and found this:

    class AdsViewModel
    {
        public int Id { get; set; }
        public  string City { get; set; }
        public string CompanyName { get; set; }
        public string ContactName { get; set; }
        public string UserEmail { get; set; }
        public string ContactPhone { get; set; }
        public string ShortTitle { get; set; }
        public string AdUrl { get; set; }
    }
    

    Changing it to:

    public class AdsViewModel 
    

    Fixed it.

提交回复
热议问题