我有一个项目列表,我可以在其中获取有关项目的所有详细信息。在项目类中,我在项目中有客户对象,我只想根据客户过滤该列表。我怎样才能做到这一点 。
public ICollection<Project> GetProjectBasicDetailsByProjectTypeCustomerID(ProjectType projectType, string custName, string cordinatorName, string projectName)
{
oLog.Debug("Started");
ISession session = DataAccessLayerHelper.OpenReaderSession();
ITransaction transaction = null;
ICollection<Project> projectList = null;
try
{
transaction = session.BeginTransaction();
ICriteria criteria = session.CreateCriteria(typeof(Project),"Project")
.CreateAlias("Project.customer","customer",NHibernate.SqlCommand.JoinType.InnerJoin)
.CreateAlias("Project.Coordinator", "Coordinator", NHibernate.SqlCommand.JoinType.InnerJoin)
.Add(Restrictions.Eq("Project.ProjectType", projectType));
projectList = criteria.List<Project>().ToList();
session.Flush();
transaction.Commit();
}
catch (Exception ex)
{
if (transaction != null && transaction.IsActive)
transaction.Rollback();
oLog.Error(ex);
}
finally
{
if (transaction != null)
transaction.Dispose();
if (session != null && session.IsConnected)
session.Close();
}
oLog.Debug("End");
return projectList;
}