views:

36

answers:

1

I have a linq query

var query = from record in session.Query<Record>()
                           from brwSet in session.Query<BorrowerSet>()
                           from brw in session.Query<Borrower>()
                           where 
                           brw.PrintOrder == 1 && brwSet.PrintOrder == 0
                           && record.Package.BorrowerSet.Contains( brwSet ) 
                           && brwSet.Borrower.Contains( brw )
                           select new Summary()
                           {
                               BorrowerFirstName = brw.Contact.FirstName,
                               BorrowerLastName = brw.Contact.LastName,
                               LoanPackageID = record.Id
                           };

how could I rewrite this to eliminate the extra from clauses

from brwSet in session.Query<BorrowerSet>()
from brw in session.Query<Borrower>()

how can I rewrite this so I don't need the contains function on these collections?

record.Package.BorrowerSet.Contains( brwSet ) && brwSet.Borrower.Contains( brw )
A: 

This query doesn't have Contains.

var query = 
  from record in session.Query<Record>()
  from brwSet in record.Package.BorrowerSet
  where brwSet.PrintOrder == 0
  from brw is brwSet.Borrowers
  where brw.PrintOrder == 1
  select new Summary()
  {
    BorrowerFirstName = brw.Contact.FirstName,
    BorrowerLastName = brw.Contact.LastName,
    LoanPackageID = record.Id
  };
David B
This does not quite work since brwSet.Borrower is a collection of borrowers.
Aaron Fischer
nhibernate 3 also does not seem to support the "from brwSet in record.Package.BorrowerSet" statement
Aaron Fischer