问题是,我的MVC应用程序与数据库连接良好,但当我查询它时,它没有返回任何东西(var model
是 empty
),我不知道问题出在哪里。SharpLite
模板,所以这已经实现了自动应用,并且正在使用 NHibernate
,我已经实现了 User
中的实体 MyProject.Domain
.以下是我的代码 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;
}
你会想看看发送到数据库的语句,以及结果,试试这些方法之一。
我对这个问题还不够了解,目前还不能确定错误。
验证您的 User
实体继承 Entity