Nhibernate 无法使用Fluent Nhibinate和MVC2在VS2010中创建强类型视图
嗨, 我想知道是否有人对VS2010 MVC 2项目在进行流畅的映射后不能自动创建强类型视图有问题 当尝试进行映射时,VS2010不会在下拉列表中显示实体,即使我手动将类放入其中,也不会自动构建视图 干杯Nhibernate 无法使用Fluent Nhibinate和MVC2在VS2010中创建强类型视图,nhibernate,visual-studio-2010,asp.net-mvc-2,fluent-nhibernate,Nhibernate,Visual Studio 2010,Asp.net Mvc 2,Fluent Nhibernate,嗨, 我想知道是否有人对VS2010 MVC 2项目在进行流畅的映射后不能自动创建强类型视图有问题 当尝试进行映射时,VS2010不会在下拉列表中显示实体,即使我手动将类放入其中,也不会自动构建视图 干杯 Dan您是否已将实体类属性公开 脚手架引擎使用.NET反射来查看传递给它的类上公开的公共属性,并将根据它的每种类型添加适当的内容 以下是我的作品: namespace Entities { public class Page { public virtual i
Dan您是否已将实体类属性公开 脚手架引擎使用.NET反射来查看传递给它的类上公开的公共属性,并将根据它的每种类型添加适当的内容 以下是我的作品:
namespace Entities
{
public class Page
{
public virtual int Id { get; private set; }
public virtual string Name { get; set; }
public virtual string Title { get; set; }
public virtual string Description { get; set; }
}
}
public class PageMap : ClassMap<Page>
{
public PageMap()
{
Table("Pages");
Id(x => x.Id);
Map(x => x.Name);
Map(x => x.Keywords);
Map(x => x.Description);
}
}
名称空间实体
{
公共类页面
{
公共虚拟整数Id{get;private set;}
公共虚拟字符串名称{get;set;}
公共虚拟字符串标题{get;set;}
公共虚拟字符串描述{get;set;}
}
}
公共类页面映射:类映射
{
公共页面地图()
{
表(“页数”);
Id(x=>x.Id);
Map(x=>x.Name);
Map(x=>x.Keywords);
映射(x=>x.Description);
}
}
强类型视图:勾选
查看数据类:实体。第页
查看内容:列表
这就产生了:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<Entities.Page>>" %>
<table>
<tr>
<th></th>
<th>
Id
</th>
<th>
Name
</th>
<th>
Title
</th>
<th>
Description
</th>
</tr>
<% foreach (var item in Model) { %>
<tr>
<td>
<%= Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) %> |
<%= Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ })%> |
<%= Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })%>
</td>
<td>
<%= Html.Encode(item.Id) %>
</td>
<td>
<%= Html.Encode(item.Name) %>
</td>
<td>
<%= Html.Encode(item.Title) %>
</td>
<td>
<%= Html.Encode(item.Description) %>
</td>
</tr>
<% } %>
</table>
<p>
<%= Html.ActionLink("Create New", "Create") %>
</p>
身份证件
名称
标题
描述
|
|
您是否已将实体类属性公开
脚手架引擎使用.NET反射来查看传递给它的类上公开的公共属性,并将根据它的每种类型添加适当的内容
以下是我的作品:
namespace Entities
{
public class Page
{
public virtual int Id { get; private set; }
public virtual string Name { get; set; }
public virtual string Title { get; set; }
public virtual string Description { get; set; }
}
}
public class PageMap : ClassMap<Page>
{
public PageMap()
{
Table("Pages");
Id(x => x.Id);
Map(x => x.Name);
Map(x => x.Keywords);
Map(x => x.Description);
}
}
名称空间实体
{
公共类页面
{
公共虚拟整数Id{get;private set;}
公共虚拟字符串名称{get;set;}
公共虚拟字符串标题{get;set;}
公共虚拟字符串描述{get;set;}
}
}
公共类页面映射:类映射
{
公共页面地图()
{
表(“页数”);
Id(x=>x.Id);
Map(x=>x.Name);
Map(x=>x.Keywords);
映射(x=>x.Description);
}
}
强类型视图:勾选
查看数据类:实体。第页
查看内容:列表
这就产生了:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<Entities.Page>>" %>
<table>
<tr>
<th></th>
<th>
Id
</th>
<th>
Name
</th>
<th>
Title
</th>
<th>
Description
</th>
</tr>
<% foreach (var item in Model) { %>
<tr>
<td>
<%= Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) %> |
<%= Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ })%> |
<%= Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })%>
</td>
<td>
<%= Html.Encode(item.Id) %>
</td>
<td>
<%= Html.Encode(item.Name) %>
</td>
<td>
<%= Html.Encode(item.Title) %>
</td>
<td>
<%= Html.Encode(item.Description) %>
</td>
</tr>
<% } %>
</table>
<p>
<%= Html.ActionLink("Create New", "Create") %>
</p>
身份证件
名称
标题
描述
|
|
看来Vs2010不喜欢与Nhibinate 3有关。即使重新链接回v3,链接到v2似乎也能使其按要求工作
非常奇怪看起来Vs2010与Nhibinate 3无关。即使重新链接回v3,链接到v2似乎也能使其按要求工作
非常奇怪干杯-这是VS和NHab 3的错误。链接到v2可以让它看到类。干杯-这是VS和NHab 3的一个bug。链接到v2可以让它看到类。