private int FindBugIdByName(string entityName) { string hqlQuery = "from Bug as bug where bug.Name = ?"; BugDTO[] bugs = BugService.Retrieve(hqlQuery, new object[] { entityName }); if (bugs.Length == 0) { throw new BuildException(string.Format("Could not find a bug named: '{0}'.", entityName)); } return(bugs[0].BugID.Value); }