我在linq
声明中加入了一个简单的
var events = (from e in context.Events
join o in context.Offices on e.OfficeId equals o.Id
where e.StartDate >= DateTime.Now
select e)
.AsEnumerable()
.Select(x => new vm_Events()
{
Cost = x.Cost,
StartDate = x.StartDate,
EndDate = x.EndDate.HasValue ? (x.EndDate).Value : new DateTime(),
Address = x.Address,
Image = x.SupportingImage,
Info = x.Info,
Name = x.Name,
LocationName = x.LocationName,
Office =
string.Format("For more information please call the {0} office at {1}", x.Offices.Name,
x.Offices.PhoneNumber),
StateZip = string.Format("{0}, {1}, {2}", x.City, x.State, x.Zip)
}).ToList();
查询构建得很好,但是当我包含连接的offices
表时,我会给出空引用。在select e
来电之前,是否需要将.AsEnumerable()
更改为其他任何内容?
我已经确认我在办公室桌上寻找的数据不为空
答案 0 :(得分:1)
如果您没有延迟加载,则无法在 <asset:javascript src="application.js"/>
之后访问//= require bootstrap
。我建议你做两个步骤:
x.Offices.Name