Hello,
I try to find a way to filter children collection in LINQ. I know I
can enable a filter on the session, but the filter string is native
SQL, I don't want to use this.
With Criteria, I think I can use a result transformer
(Transformers.AliasToEntityMap) to achieve this, but is there a way to
do this with the new LINQ provider ?
For example, I've got two classes :
public class ThirdParty : Entity
{
public virtual string FirstName { get; set; }
public virtual string LastName { get; set; }
public virtual ThirdParty CurrentParent
{
get
{
var thirdPartyAssignment =
Assignments.FirstOrDefault(tpa => tpa.EndDate == null);
return thirdPartyAssignment == null ? null :
thirdPartyAssignment.ThirdParty;
}
}
public virtual IEnumerable<ThirdPartyAssignment> Assignments
{ get; set; }
}
public class ThirdPartyAssignment : Entity
{
public virtual ThirdParty ThirdParty { get; set; }
public virtual ThirdParty Parent { get; set; }
public virtual DateTime? EndDate { get; set; }
}
Sometimes, I want all the ThirdParties with all the Assignments (in
this case, session.Query<ThirdParty>() works well). Other times, I
want the ThirdParties with only the Assignments where EndDate is null.
I didn't succeed to do this with the LINQ provider.
Cordially,
Kakone.
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.