本文主要是介绍NHibernate(one-to-many)的问题,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
有2个表:Category(父表)和Product(子表)CREATE TABLE [Category] (
[ID] [varchar] (10) NOT NULL ,
[Name] [varchar] (80) NOT NULL ,
[Description] [varchar] (50) NULL
)
CREATE TABLE [Product] (
[ID] [varchar] (10) NOT NULL ,
[CategoryID] [varchar] (10) NOT NULL ,
[Name] [varchar] (50) NOT NULL ,
[Description] [varchar] (50) NULL
)
//下面能正确运行
IList data = vSession.Find("select p.Name from Product as p left outer join p.Categorys as c where c.ID='1'");
//而写成下面的语句却提示:coult not excute query
IList data = vSession.Find("from Product as p left outer join p.Categorys as c where c.ID='1'");
后来终于找到答案:因为两个表都有ID这个字段,所有NH0.6.0.0分不清楚了,
这篇关于NHibernate(one-to-many)的问题的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!