-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: How to user DetachedCriteria parent Criterion {alias}
PostPosted: Wed Aug 04, 2010 10:57 pm 
Newbie

Joined: Wed Aug 04, 2010 10:52 pm
Posts: 2
[NUnit.Framework.Test]
public void SubFieldQuery()
{
var session = Z.Core.NHibernateCore.NHibernateHelper.GetCurrentSession();
var subCrit = NHibernate.Criterion.DetachedCriteria.For<Model.Sys.Manager>("M");
subCrit.SetProjection(NHibernate.Criterion.Projections.Property("Name"));
subCrit.SetMaxResults(1);
//subCrit.Add(NHibernate.Criterion.Expression.EqProperty("M.ParentCompany.Guid", "C.Guid")); //that is right
//but I want user Expression.Sql
subCrit.Add(NHibernate.Criterion.Expression.Sql("Convert(nvarchar(50),{alias}.CompanyGuid) = this_.Guid"));
//The result is correct, but "this_.Guid" => how to use "{alias.Criterion}.Guid" or "{alias.Parent}.Guid"
//Thanks

var crit = session.CreateCriteria<Model.Sys.Company>("C");
crit.SetProjection(NHibernate.Criterion.Projections.ProjectionList()
.Add(NHibernate.Criterion.Projections.SubQuery(subCrit)));
var list = crit.List();
Console.Write(list.Count);
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.