Hi !
This is my model
Entity_A_Parent |
ID_A (PK) |
Entity_C_Link |
ID (PK) |
ID_B (PK) |
I use GetMulti
on Entity_B_Child
.
When I tried to add relation to Entity_C_Link
relations.Add(Entity_B_Child.Relations.Entity_C_LinkEntityUsingEntity_B_ChildId_A);
When the app run Entity_B_Child.GetMulti(filter, maxTotalRecordCount, defaultSort, relations, startIndex_1base, pageSize);
An exception has throwed :
SD.LLBLGen.Pro.ORMSupportClasses.ORMRelationException: 'Relation at index 1 doesn't contain an entity already added to the FROM clause. Bad alias?'
Thanks for your help.
Update:
Model:
CatKeyword |
ID (PK) |
CAT_ID (FK) |
KEYWORD_ID (FK) |
public CatCollection SearchEvents(Criteria criteria)
{
var cats = new CatCollection();
IRelationCollection relations = new RelationCollection();
IPredicateExpression filter = new PredicateExpression();
if (critere.Keywords.Any())
{
relations.Add(CatKeywordEntity.Relations.CatEntityUsingCatId);
var filterKeyword = new FieldCompareRangePredicate(CatKeywordFields.KeywordId, critere.Keywords);
filter.AddWithAnd(filterKeyword);
}
int pageNumber = criteria.PageIndex + 1;
int pageSize = criteria.PageSize;
int startIndex = (pageNumber > 1) ? checked((pageNumber - 1) * pageSize) : 0;
int startIndex_1base = startIndex + 1;
SortExpression defaultSort = new SortExpression(new SortClause(CatFields.Date, SortOperator.Descending));
int maxTotalRecordCount = SetMaxRecordSize(pageSize);
cats.GetMulti(filter, maxTotalRecordCount, defaultSort, relations, startIndex_1base, pageSize);
int totalRecordCount = Math.Min(cats.GetDbCount(filter, relations), maxTotalRecordCount);
return cats;
}
Items In relation collection :
[0] {CatKeyworkEntity.(CatId) m:1 CatEntity.(Id)}
[1] {AnimalEntity.(Id) 1:1 CatEntity.(Id) (Hierarchy relation)}