I am trying to join aliases multiple times but it depends on the number of times it should do it.
Employee employeeAlias = null;
Thing thingAlias = null;
var names = string[] {"A", "B", "C", "D", "E"} // number of values could vary
for(int i = 0; i < names.Length ; i++)
{
queryOver
.JoinAlias(() => employeeAlias.Things,
() => thingAlias,
JoinType.LeftOuterJoin,
Restrictions.Eq(Projections.Property(() => thingAlias.Name,
names[i]));
}
However, upon execution, NHibernate throws an error saying:
NHibernate.QueryException: duplicate alias: thingAlias ---> System.ArgumentException: An item with the same key has already been added
Is there a way I can make NHibernate join an alias with a specified name so that it will not re-use the name of the variable?
Thanks guys. This has been my problem since yesterday and I can't find a proper solution.
PS:
I'm trying to do something like this:
SELECT * FROM Employee e
LEFT OUTER JOIN Thing t on e.Id = t.EmployeedId AND t.Name = "A"
LEFT OUTER JOIN Thing t on e.Id = t.EmployeedId AND t.Name = "B"