【发布时间】:2012-03-23 03:24:56
【问题描述】:
问题是我的 MVC 应用程序可以很好地连接到我的数据库,但是当我查询它时它没有返回任何内容(var model 是 empty)而且我不知道是什么问题。我正在使用SharpLite 模板,所以它已经实现了自动映射,并使用NHibernate 连接到我的数据库,我已经在MyProject.Domain 中实现了User 实体。
这是我User Controller中的代码:
private readonly IRepository<User> _repository;
public UserController(IRepository<User> repository)
{
_repository = repository;
}
public ActionResult Index()
{
var model = _repository.GetAll();
return View(model);
}
这是来自NHibernate initializer的代码:
public static Configuration Initialize()
{
var configuration = new Configuration();
configuration
.Proxy(p => p.ProxyFactoryFactory<DefaultProxyFactoryFactory>())
.DataBaseIntegration(db => {
db.ConnectionStringName = "MyProjectConnectionString";
db.Dialect<PostgreSQL82Dialect>();
})
.AddAssembly(typeof(ActionConfirmation<>).Assembly)
.CurrentSessionContext<LazySessionContext>();
var mapper = new ConventionModelMapper();
mapper.WithConventions(configuration);
return configuration;
}
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-3 model-view-controller nhibernate nhibernate-mapping