In the entity framework we can achieve eagar loading by using "include". I have written the following query for eagar loading in NHibernate linq.
IList empl = Session.CreateCriteria(typeof(Employee))
.Add(Expression.Like("Name", "Pete%"))
.SetFetchMode("Name", FetchMode.Eager)
.SetFetchMode("Desigantion", FetchMode.Eager)
.List();
Can any one give me better example of eagar and lazy loading in the NHibernate Linq. I have following Mapping in fluent Nhibernate:
Table("DEMO_Employee");
Id(t => t.Id).Column("Id").GeneratedBy.Identity();
Map(t => t.Name, "Name");
Map(t => t.Designation, "Designation");
Map(t => t.Gender, "Gender");
Map(t => t.Age, "Age");
Map(t => t.Enabled, "Enabled");
Map(t => t.CreatedById).Column("CreatedBy");
Map(t => t.LastModifiedById).Column("LastModifiedBy").Nullable();
Map(t => t.IsDeleted).Column("IsDeleted");
Map(t => t.CreatedDate).Column("CreatedDate");
Map(t => t.LastModifiedDate).Column("LastModifiedDate").Nullable();
References(x => x.Department).ForeignKey("DeptId");
Table("DEMO_Department");
Id(t => t.DeptId).Column("DeptId").GeneratedBy.Identity();
Map(t => t.DeptName, "DeptName");
Map(t => t.Enabled, "IsEnable");