从nhibernate 3.0查询xml列
我的一个实体中有一个xml列从nhibernate 3.0查询xml列,xml,nhibernate,xpath,xquery,Xml,Nhibernate,Xpath,Xquery,我的一个实体中有一个xml列 我想使用一个用户类型,并将此列映射到我的XmlElement类型实体中的属性。 我想知道是否可以像使用QueryOver查询sql一样从代码中查询此对象? 我发现了这样的东西。但我不知道该如何去质疑它 提前谢谢你好吧,我就是这样做的 不是最常见的代码 但无论如何… 我使用UnderlineCriteria属性将查询版本与sql限制组合起来 我需要使用别名进行限制,因为nhibernate源代码中有一行代码查找别名并获取从开始到别名的子字符串 如果您不提供别名,显然它
我想使用一个用户类型,并将此列映射到我的XmlElement类型实体中的属性。
我想知道是否可以像使用QueryOver查询sql一样从代码中查询此对象?
我发现了这样的东西。但我不知道该如何去质疑它
提前谢谢你好吧,我就是这样做的
不是最常见的代码
但无论如何…
我使用UnderlineCriteria属性将查询版本与sql限制组合起来
我需要使用别名进行限制,因为nhibernate源代码中有一行代码查找别名并获取从开始到别名的子字符串
如果您不提供别名,显然它会失败
if (tagIds != null && tagIds.Count > 0)
{
StringBuilder attrXPath = new StringBuilder();
for(int counter = 0;counter<tagIds.Count();counter++)
{
attrXPath.Append("@id=\"");
attrXPath.Append(tagIds[counter]);
attrXPath.Append("\"");
if(counter < tagIds.Count() - 1)
attrXPath.Append(" or ");
}
query.UnderlyingCriteria
.Add(Restrictions.Eq(Projections.SqlProjection("tags.exist('/tags/tag[" + attrXPath.ToString() + "]') as XmlRestriction",
new string[] { "XmlRestriction" },
new IType[] { NHibernateUtil.String}), 1));
}
if(tagIds!=null&&tagIds.Count>0)
{
StringBuilder attrXPath=新的StringBuilder();
对于(int counter=0;counter)您的意思是在代码中查询它……或者在db中运行查询?@Thilak Nathen,在代码中明确地查询它