filter - NHibernate criteria on lazyload -
Can anyone tell me that it is possible to add benchmarks in the NHibernate lazy load collection.
For example, suppose I have a department in which the employee is involved ... I get a department from ID and then I load lazy employees ... but can say that 1000 There are employees and I want only those employees who were hired in the last 30 days.
GetDeptById (1)
& nbsp; & Nbsp; & Nbsp; |
& nbsp; & Nbsp; & Nbsp; - Lazy Load Employee (where HigherData = 7/1/2009)
It seems that I can do this with the filter in the mapping file ... but will I do something for the lazy load in the code Can I add criteria?
The best way to apply this would be with a filter filter in mapping (both unit and bag) Define and then select the date you want the filter with the parameter before selecting "department".
session.EnableFilter ("HireDateFilter"). SetParameter ("dateParameter", date time.NEW ADADEZ (-30));
You can also leave the mapping and apply a custom defined filter to the lazy loaded archive.
session.CreateFilter (department.Employees, "Hiredat> =: Date Parameter"). Setpalmator ("DatePamator", DateTime.Now; AUD (-30));
If the only thing you want to do is ban, then I like the mapping-filter option because in this way you can get select curiosity, this Like the Object Graph in the same selection.
If you want to do additional operations (like paging) CreateFilter will be better, however, for the more complex scenarios, the targeted query to the employee will be a better IOO.
Comments
Post a Comment