I think found your error. Is in this line:
onClause.AddWithAnd((EntityField2)dimensionEntity.GetEntityFactory().CreateFields()["DimensionCode"] == 0);
Do you see it? CusttableEntity doesn't have any field with name "DimensionCode" you mistyped the field name. As the field doesn't exist it is not added to the predicate expression tree. Then LLBLGen emits the sql code but there is a missing element, that's why Sql connector complains.
It should be Dimensioncode (as you write few lines before). If you change that line this way:
onClause.AddWithAnd((EntityField2)dimensionEntity.GetEntityFactory().CreateFields()["Dimensioncode"] == 0);
...everything work as expected.
I found that because there was too much code so I first rewrote it:
// my dynList
var fields = new ResultsetFields(6);
fields.DefineField(CusttableFields.Accountnum, 0, "a");
fields.DefineField(CusttableFields.Name, 1, "b");
fields.DefineField(CusttableFields.Dimension, 2, "c");
fields.DefineField(DimensionFields.Num, 3, "d");
fields.DefineField(DimensionFields.Dimensioncode, 4, "e");
fields.DefineField(DimensionFields.Description, 5, "f");
// ON CLAUSE
IPredicateExpression onClause = new PredicateExpression();
onClause.Add(CusttableFields.Dimension == DimensionFields.Num);
onClause.AddWithAnd(CusttableFields.Dataareaid == DimensionFields.Dataareaid);
onClause.AddWithAnd(DimensionFields.Dimensioncode == 0);
// the dynRelation
DynamicRelation relation = new DynamicRelation(EntityType.CusttableEntity, JoinHint.Left, EntityType.DimensionEntity,
string.Empty, string.Empty, onClause);
// the filter
RelationPredicateBucket filter = new RelationPredicateBucket(CusttableFields.Dataareaid == "USA");
filter.Relations.Add(relation);
// fetch
DataAccessAdapter adapter = new DataAccessAdapter();
DataTable dynamicList = new DataTable();
adapter.FetchTypedList(fields, dynamicList, filter);
So. as a personal recommendation I suggest to use directly the Field properties instead of abuse of string-base accessors, that is not friendly when you need to make entity field name changes and regenerate code. It's just a recommendation
as I don't know the situation and requirements of your project.
Hope helpful