0
我使用NHibernate ORM和MySql數據庫作爲我的APP。我爲我的類別使用簡單的嵌套表模型。NHibernate分層遞歸查詢
我的表的SQL:
CREATE TABLE `cat` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`catId` int(11) DEFAULT '0',
`dr` bit(1) DEFAULT NULL,
`st` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
) ENGINE=MyISAM AUTO_INCREMENT=25 DEFAULT CHARSET=utf8;
我的類別類:
public class cat
{
[Key]
public virtual int id { get; set; }
public virtual int catId { get; set; }
public virtual bool dr { get; set; }
public virtual DateTime st { get; set; }
[ForeignKey("catId")]
public virtual IList<cat> cats { get; set; }
}
我怎樣才能做到這一點查詢與NH:
select t2.* from (select id from cat where catId=0 and dr=1) t1 join
cat t2 On(t1.id=t2.catId) where t2.st<Now() and t2.dr=1;