我收到此错误"System.NotSupportedException:无法在LINQ to Entities查询中构造实体或复杂类型'MyModel.Team'." 当我导航到Team/Index/{id}页面时.有人能指出我做的错误吗?
控制器:
public ActionResult Index(int id)
{
IQueryable<Team> teams = teamRepository.GetTeamByPersonID(id);
return View("Index", teams);
}
Run Code Online (Sandbox Code Playgroud)
库:
public IQueryable<Team> GetTeamByPersonID(int id)
{
return from t in entities.Teams
join d in entities.Departments
on t.TeamID equals d.TeamID
where (from p in entities.Person_Departments
join dep in entities.Departments
on p.DepartmentID equals dep.DepartmentID
where p.PersonID == id
select dep.TeamID).Contains(d.TeamID)
select new Team
{
TeamID = t.TeamID,
FullName = t.FullName,
ShortName = t.ShortName,
Iso5 = t.Iso5,
DateEstablished = t.DateEstablished,
City = t.City,
CountryID = …Run Code Online (Sandbox Code Playgroud) 我在这种格式的文件夹中有很多文件
constant_blah_blah_blah.png
Run Code Online (Sandbox Code Playgroud)
如何用空格替换下划线并使用PowerShell从中删除constant_?
提前致谢.
我想格式化TextBoxes中显示的DateTime,没有时间和格式:2011年1月1日,而不是显示和编辑方案的默认01/01/2011.
我已经使用DateTime的以下模板来使用datepicker.我可以在某种程度上包括格式吗?
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<System.DateTime?>" %>
<%: Html.TextBox("",ViewData.TemplateInfo.FormattedModelValue, new { @class = "text-box single-line" }) %>
Run Code Online (Sandbox Code Playgroud)
提前致谢.
我在视图中使用以下代码,我试图在最后使用附加参数添加撤销链接但我收到以下错误:
System.ArgumentException:参数字典包含'MaxMe2.Controllers.TeamController中方法'System.Web.Mvc.ActionResult Withdraw(Int32,Int32)'的非可空类型'System.Int32'参数'personID'的空条目".可选参数必须是引用类型,可空类型,或者声明为可选参数.
<% if(Model.departmentsDisplayCheck) {%>
<table>
<tr>
<th>Name</th>
<th>Type</th>
<th>Status</th>
</tr>
<% foreach (var dep in Model.departmentsList){ %>
<tr>
<td><%: Html.ActionLink(dep.Name, "Details", "Department", new { id=dep.DepartmentID}, null) %></td>
<td><%: dep.DepartmentType.Type %></td>
<td><%: dep.DepartmentStatus.Status %></td>
<td><%: Html.ActionLink("Withdraw", "Withdraw", "Team", new { id = Model.personalInfo.PersonID, dep = dep.DepartmentID}, null)%></td>
</tr>
<% } %>
Run Code Online (Sandbox Code Playgroud)
我试图调用的控制器方法是这样的:
public ActionResult Withdraw(int personID, int departmentID)
{
.....
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?提前致谢!