【发布时间】:2014-07-15 12:27:47
【问题描述】:
运行时错误,说明标题显示的内容... 我的 Linq 在我的控制器中如下所示:
var TestingLinq = (from a in db.shp_master
join b in db.shp_status on a.serialnbr equals b.serialnbr into b_join
from b in b_join.DefaultIfEmpty()
where
a.shipto == "1022a" &&
a.status == "s" &&
b.status == "s" &&
a.shpreq == 0
group new {a, b} by new {
a.serialnbr,
a.trailer,
a.shipto
} into g
orderby
g.Key.serialnbr
select new RecieveTruck {
SerialNumber = g.Key.serialnbr,
TrailerNumber = (g.Key.trailer ?? "N/A"),
Shipped = g.Min(p => p.b.datetimestamp),
ETA = null,
ShipTo = g.Key.shipto == "1026" ? (System.DateTime?)Convert.ToDateTime(g.Min(p => p.b.datetimestamp)).AddMinutes(180) :
g.Key.shipto == "2020" ? (System.DateTime?)Convert.ToDateTime(g.Min(p => p.b.datetimestamp)).AddMinutes(195) :
g.Key.shipto == "2017" ? (System.DateTime?)Convert.ToDateTime(g.Min(p => p.b.datetimestamp)).AddMinutes(180) :
g.Key.shipto == "nor" ? (System.DateTime?)Convert.ToDateTime(g.Min(p => p.b.datetimestamp)).AddMinutes(180) : null
});
return View(TestingLinq);
然后在我看来,我有以下几点:
@model IEnumerable<TestingMainPage.Models.RecieveTruck>
@if (Model.Count() > 1 )
{
foreach (var tl in Model)
{
<tr>
<td align="center" valign="middle" nowrap="nowrap" class="bodyTextTL"><img src="~/Content/images/view.gif" alt="View Load" style="cursor:pointer;" onclick="document.location.href = '/RecieveTruck/ViewLoad?LoadID=' + @tl.SerialNumber + ''" /></td>
<td align="center" valign="middle" nowrap="nowrap" class="bodyTextTL">@tl.SerialNumber</td>
<td align="center" valign="middle" nowrap="nowrap" class="bodyTextTL">@tl.TrailerNumber</td>
<td align="center" valign="middle" nowrap="nowrap" class="bodyTextTL">@tl.Shipped</td>
<td align="center" valign="middle" nowrap="nowrap" class="bodyTextTL">@tl.ETA</td>
<td align="center" valign="middle" nowrap="nowrap" class="bodyTextTLR">
<input type="button" name="Receive Load" value="Receive Load" style="cursor: pointer;" class="bodyText6" onmouseover="this.style.color='orangered'; this.style.fontWeight='bold';" onmouseout=" this.style.color='black'; this.style.fontWeight='normal';" onclick="document.location.href = '/RecieveTruck/Execute'" /> 
</td>
</tr>
}
}
所以我的问题是,我如何将它传递给我的视图,以便我可以使用它来填充我在我的网络程序上创建的表格.. 我明白为什么它在运行它之前不会给我一个错误,但是我应该如何将它传递给我的视图?
【问题讨论】:
-
您了解错误的含义以及为什么会出现错误吗?
-
尝试使用SqlFunctions 方法。提供程序无法将
AddMinutes转换为 SQL。 -
而对于那些使用EF的,还有EntityFunctions
-
@deherch,应该发帖而不是评论