pen*_*ake 1 .net nhibernate antlr
我无法理解为什么不创建这个简单的查询.我从一个测试中调用这个方法,并抛出一个异常抱怨第1行,第7列,我看不出有什么问题.
public IList<Continent> GetContinentByName(string name)
{
ISession session = GetSession();
IQuery query =
session.CreateQuery("select from Continent where Continent.ContinentShort='Atlantis'");
// (........) Next step will be getting the list from the query if I can make it work
Run Code Online (Sandbox Code Playgroud)
我在下面得到了例外情况
TestCase'M:DataAccessLayer.HibernateDataProvider.GetContinentByName(System.String)'失败:抛出了类型'Antlr.Runtime.NoViableAltException'的异常.在第1行第7列附近NHibernate.Hql.Ast.ANTLR.QuerySyntaxException:抛出了类型'Antlr.Runtime.NoViableAltException'的异常.靠近第1行第7列
有什么建议?
谢谢
session.CreateQuery驱逐HQL查询,如下所示:
sess.CreateQuery("from DomesticCat cat where cat.Name in (:namesList)");
如果您尝试推送本机SQL查询,则必须执行以下操作:
session.CreateSQLQuery("SELECT {cat.*} FROM CAT {cat} WHERE ROWNUM<10", "cat", typeof(Cat))
但是,这不是使用NHibernate的好方法.
有关详细信息,请参阅Nhibernate文档:http://nhibernate.info/doc/nh/en/index.html#manipulatingdata-querying
| 归档时间: |
|
| 查看次数: |
7079 次 |
| 最近记录: |