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

Commit 2955ec5

Browse files
authored
Enhance CustomJoin (#666)
1 parent f3d1b42 commit 2955ec5

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/ServiceStack.OrmLite/Expressions/SqlExpression.Join.cs

+14
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,20 @@ public List<ModelDefinition> GetAllTables()
3131
return allTableDefs;
3232
}
3333

34+
public SqlExpression<T> AddReferenceTableIfNotExists<Target>()
35+
{
36+
var tableDef = typeof(Target).GetModelDefinition();
37+
if (!tableDefs.Contains(tableDef))
38+
tableDefs.Add(tableDef);
39+
return this;
40+
}
41+
42+
public SqlExpression<T> CustomJoin<Target>(string joinString)
43+
{
44+
AddReferenceTableIfNotExists<Target>();
45+
return CustomJoin(joinString);
46+
}
47+
3448
public bool IsJoinedTable(Type type)
3549
{
3650
return tableDefs.FirstOrDefault(x => x.ModelType == type) != null;

0 commit comments

Comments
 (0)