I'm not sure if this is a bug or not, but when I try to add a CustomFilter to a relation, the alias that I use in the CustomFilter, doesn't match the LLBLGenPro genearated alias, thus causing an error in SQL.
Here is an example of the relation that i'm adding:
IEntityField2 cpField = EntityFieldFactory.Create(CustomPropertyFieldIndex.CustomPropertyID);
//cpField.SetObjectAlias("cpv");
bucket.Relations.Add(ContactEntity.Relations.CustomPropertyValueEntityUsingNSEntityKey, "cpv", JoinHint.Left).CustomFilter =
new PredicateExpression(new FieldCompareValuePredicate(
cpField, null, ComparisonOperator.Equal, cp.CustomPropertyID, "cpv"));
note. cp.CustomPropertyID is an integer being declared outside the scope of the function.
Here is the Generated SQL for that statement:
LEFT JOIN [DEV].[dbo].[CustomPropertyValue] [LPA_c4]
ON [DEV].[dbo].[Contact].[ContactID]=[LPA_c4].[NSEntityKey]
AND ( [cpv].[CustomPropertyID] = @CustomPropertyID2)) LEFT JOIN
As you can see, the AND claus of the SQL query uses my Alias rather then the LLBLGenPro generated alias. Could this be a bug with 1.0.2005.1? Is there something that I need to add to make sure the alias gets converted to the LLBLGenPro alias? Is there a way to dynamically turn off the LLBLGenPro converted aliases?
I've tried many many combinations of FieldCompare functions, and all of them have the same result when creating the CustomFilter predicate expression.