I am using the Nhibernate.Linq binary from NHibernate Contrib. I have
the following class definition:

    public class Repository<T> : IRepository<T>
    {
        public IList<T> FindAll(IList<Func<T, bool>> criteria)
        {
            ISession session = SessionManager.GetCurrentSession();
            IQueryable<T> query = from item in session.Linq<T>()
                                  select item;

            foreach (var criterion in criteria)
            {
                query.Where<T>(criterion);

            }


            return query.ToList();
        }
    }


I am using it like this:

var timecardRepository = new Repository<Timecard>();

IList<Func<Timecard, bool>> criteria = new List<Func<Timecard, bool>>
();
criteria.Add(x => x.EmployeeID == 1);

var count = 0;
foreach(var timecard in timecardRepository.FindAll(criteria))
{
   //Console.WriteLine("T {0} [{1}] {2}", timecard.TimecardID,
timecard.EmployeeID, timecard.EmployeeSigned);
   count++;
}


This returns all of the records in the database, and does not filter
on the EmployeeID like I expected it to. It appears the Where() clause
is ignored.

I turned on SQL output in Fluent NHibernate and this is what I see:

NHibernate: SELECT this_.TimecardsID as Timecard1_0_0_,
this_.EmployeeSigned as Employee2_0_0_, this_.EmployeesID as
Employee3_0_0_ FROM dbo.Timecards
this_


No where clause to be found.

Any clues?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to