问题描述
我是nHibenate的新手,正在处理问题,以下是我的课程:
public class CustomerEntity
{
public virtual int CustomerId
{
get;
set;
}
public virtual string Name
{
get;
set;
}
public virtual string Fname
{
get;
set;
}
public virtual string Phone
{
get;
set;
}
}
}
和我不知道其映射类是否正确的映射类:
public class CustomerMap : ClassMap<CustomerEntity> {
public CustomerMap()
{
Map(x => x.CustomerId);
Map(x => x.Name);
Map(x => x.Fname);
Map(x => x.Phone);
}
}
我有一个记录,我想简单地将其返回,我的控制器:
public IActionResult Get()
{
var books = _session.Customer();
return Ok(books);
}
这是我的服务
public IEnumerable<CustomerEntity> Customer()
{
IList<CustomerEntity> cust =
_session.Query<CustomerEntity>()
.ToList();
return cust;
}
我的会话工厂:
public static ISessionFactory BuildSessionFactory(string DefaultConnection,bool create = false,bool update = false)
{
return Fluently.Configure().Database
(MsSqlConfiguration.MsSql2012.ConnectionString
(System.Configuration.ConfigurationManager.
ConnectionStrings[DefaultConnection]
.ConnectionString).ShowSql())
}))
.Mappings(m =>
m.FluentMappings
.AddFromAssemblyOf<CustomerEntity>())
.ExposeConfiguration(cfg => new SchemaExport(cfg)
.Create(false,false))
.BuildSessionFactory();
}
但是查询返回[]表示空,并且我没有任何错误,知道吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)