Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 262be4a

Browse files
committed
Change to use qualified field name of modelDef in self-ref fields
1 parent 50dd79b commit 262be4a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/ServiceStack.OrmLite/Support/LoadList.cs

+5-4
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,11 @@ protected void SetListChildResults(FieldDefinition fieldDef, Type refType, IList
8787
}
8888
}
8989

90-
protected string GetRefSelfSql(FieldDefinition refSelf, ModelDefinition refModelDef)
90+
protected string GetRefSelfSql(ModelDefinition modelDef, FieldDefinition refSelf, ModelDefinition refModelDef)
9191
{
9292
//Load Self Table.RefTableId PK
93-
expr.Select(dialectProvider.GetQuotedColumnName(refModelDef, refSelf));
93+
expr.Select(dialectProvider.GetQuotedColumnName(modelDef, refSelf));
94+
9495
var subSqlRef = expr.ToSelectStatement();
9596

9697
var sqlRef = "SELECT {0} FROM {1} WHERE {2} IN ({3})".Fmt(
@@ -182,7 +183,7 @@ public void SetRefField(FieldDefinition fieldDef, Type refType)
182183

183184
if (refSelf != null)
184185
{
185-
var sqlRef = GetRefSelfSql(refSelf, refModelDef);
186+
var sqlRef = GetRefSelfSql(modelDef, refSelf, refModelDef);
186187
var childResults = dbCmd.ConvertToList(refType, sqlRef);
187188
SetRefSelfChildResults(fieldDef, refModelDef, refSelf, childResults);
188189
}
@@ -229,7 +230,7 @@ public async Task SetRefFieldAsync(FieldDefinition fieldDef, Type refType, Cance
229230
}
230231
else if (refSelf != null)
231232
{
232-
var sqlRef = GetRefSelfSql(refSelf, refModelDef);
233+
var sqlRef = GetRefSelfSql(modelDef, refSelf, refModelDef);
233234
var childResults = await dbCmd.ConvertToListAsync(refType, sqlRef, token);
234235
SetRefSelfChildResults(fieldDef, refModelDef, refSelf, childResults);
235236
}

0 commit comments

Comments
 (0)