Fabrice wrote:
I tried to make something but there no field to put on join in my query so how can I do that ?
I've something like that :
IEntityRelation relation = new EntityRelation(RelationType.OneToMany);
relation.AddEntityFieldPair(EntityFieldFactory.Create(?), EntityFieldFactory.Create(?));
relation.SetAliases("t1", "t2");
Remember my query :
SELECT T2.*
FROM MYTABLE T1, MYTABLE T2
WHERE
(T1.LEFT BETWEEN T2.LEFT AND T2.RIGTH) AND
(T1.ID = XX)
Let me rewrite that using ansi-joins, as you're using SqlServer:
SELECT T2.*
FROM MyTable T1 INNER JOIN MyTable T2
ON T1.somefield = T2.somefield
WHERE (T1.LEFT BETWEEN T2.LEFT AND T2.RIGHT) AND
(T1.ID = XX)
is this what you want or do you want this:
SELECT T2.*
FROM MyTable T1 INNER JOIN MyTable T2
ON (T1.LEFT BETWEEN T2.LEFT AND T2.RIGHT)
WHERE (T1.ID = XX)
The first is doable by specifying MyTableFieldIndex.SomeField for the field index at the '?'.
The second isn't doable in 1.0.2004.1, this is only doable in 1.0.2004.2, I've added that feature yesterday by adding a simple flag what to do with the CustomFilter added to an entityrelation object: replace the ON filter or append it to the filter. (this build hasn't been uploaded though)
So as you specified it in non-ansi joins, it was a bit unclear to me what you want, as with non-ansi joins the ON clause is also specified in the where clause, though I suspect you want the second option.