Thank you Vladislav for the reply. I am facing a scenario like

I have to strictly match 3 columns of parent and 2 columns from child with 
the given set of input criterias.
Colum1Val, Column2Val and Column3Val must exactly match with Column4Val and 
Column5 val of child record

I meant to say that if detachedcriteria is being used the possibility is 
the column4val and column5val of child doesn't match with column1val and 
other column.

It is like if parent has column1, column2,column3 as with values Colum1Val, 
Column2Val and Column3Val
then its child must have value column4val and column5val only. This sort of 
strict matching is to be done.

Using CreateAlias tried to fetch records but when distinct 
or .SetResultTransformer(new DistinctRootEntityResultTransformer()) is not 
being used then, it results in the child records count.

So if a parent is having 6 childs and I apply distinct to it, I get a 
single record.

If I set setmax records without distinct I get the childs while I need 
distinct parent with the setmaxrecord count.

I think I am unable to place the query clearly in front of you :(

On Thursday, February 21, 2013 8:00:49 PM UTC+5:30, Vladislav wrote:
>
> Now i solve it by using code like 
>
>             var subCriteria = DetachedCriteria.For<Company>("companyDT")
>                 .CreateCriteria("Translations")
>                 .Add(!Restrictions.Eq("Locale", locale))
>                 
> .SetProjection(Projections.Distinct(Property.ForName("companyDT.CompanyId")));
>
>
>
> query.CreateCriteria("Translations", "translations")
>
>                                .Add(Expression.Disjunction()
>                                               .Add(Restrictions.Eq("Locale", 
> locale)) // We select all elements from needed locale, and other elements 
> that not selected yet.
>                                               
> .Add(Property.ForName("company.CompanyId").In(subCriteria)))
>                                .AddOrder(new 
> Order(Projections.SqlProjection(string.Format("case when {{alias}}.Locale = 
> '{0}' then 1 else 0 end as order", locale), new[] { "order" }, 
>                                    new[] { NHibernateUtil.String }), false))
>
>
> четверг, 21 февраля 2013 г., 10:42:44 UTC+2 пользователь 
> [email protected] написал:
>>
>> Hi NHGroup,
>>
>> My scenario is like I have a parent child relationship where a parent can 
>> have multiple childs and in parent mapping I have bag for child.
>>
>> I want to construct a query which would at a time match 3 columns of 
>> parent and 2 columns of child, and I get the inputs in sets such as if i 
>> get 10 inputs then each contain 3 input parameter for Parent and 2 for 
>> child.
>>
>> If a perform a create alias then join happens and suppose if for a parent 
>> it has 6 childrens then if all the criteria match then I end up with 6 
>> records but when applying distinct or .SetResultTransformer(new 
>> DistinctRootEntityResultTransformer())
>>
>> I end up with a single parent record. My objective is to fetch counts of 
>> parent not of childrens. How may I put it.
>>
>> Means SetMaxResults(count).distinct() must fetch me for parent while it 
>> happens that if I remove distinct() then it fetches the childs and when 
>> distinct is applied I end up with a single parent.
>>
>> How can I query such that I can match parent as well as child at a time 
>> with .SetmaxResults() to fetch max results of parents? Please give me some 
>> suggestions about it.
>>
>> Thanks & Regards,
>> Vinay Sulanki
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to