Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/274.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 对象不包含标题的定义_C#_Asp.net Mvc 3 - Fatal编程技术网

C# 对象不包含标题的定义

C# 对象不包含标题的定义,c#,asp.net-mvc-3,C#,Asp.net Mvc 3,我有一个控制器,通过ViewBag将数据传递给我的视图 我的控制器: var aJobs = from a in gdb.AcceptedJobs where a.Job.EmployerID == (Guid)Session["UserID"] && !a.Archived select new { a.Job.Title, a.Job.Address }; ViewBag.jobs = aJobs; return View("E

我有一个控制器,通过ViewBag将数据传递给我的视图

我的控制器:

var aJobs = from a in gdb.AcceptedJobs
            where a.Job.EmployerID == (Guid)Session["UserID"] && !a.Archived
            select new { a.Job.Title, a.Job.Address };
ViewBag.jobs = aJobs;
return View("Employer");
我的看法是:

foreach (var job in ViewBag.jobs)
{
    @job.Title
    @job.Address
}
现在,当我浏览到页面时,在
@job.Title
,我发现错误
对象不包含Title
的定义,这是为什么


我正在使用ASP.NETMVC3 C 35;

尝试用这种方式创建匿名类型

select new { Title = a.Job.Title, Address = a.Job.Address };

当我调试时,错误被抛出,我检查了局部变量。然后我可以清楚地看到,在第一次迭代中,job对象包含一个标题字符串,其值为my name

请仅对实际答案使用“发布答案”按钮。您应该修改原始问题以添加其他信息。