i have Project and Customer Model.
Project model have Customer object with <many-to-one>
mapping.in database this may b the case where customer is exist but it not have entry in project table.
i m doing CustomerSearch functionality in which user can enter project or customer name.if user enters customername only then i want all the records which are matching with CustomerName without considering that customer have project or not.
i tried this in Service.
ICriteria criteria = session.CreateCriteria(typeof(Project),"Project")
.CreateAlias("Project.customer","customer",NHibernate.SqlCommand.JoinType.RightOuterJoin)
.CreateAlias("Project.Coordinator", "Coordinator", NHibernate.SqlCommand.JoinType.InnerJoin);
if (!string.IsNullOrEmpty(custName))
{
criteria.Add(Expression.Like("customer.Name", custName, MatchMode.Start));
}
if (!string.IsNullOrEmpty(projectName))
{
criteria.Add(Expression.Like("Project.Name", projectName, MatchMode.Start));
}
projectList = criteria.List<Project>().ToList();
i used RightOuterJoin to Customer because project table may not have record of customer but customer table must have those records.
This code is not giving any error also if i see projectList
it have list but some items who don't have record in project table that is null.
How can i get such records?