Reputation: 1765
This is a bit related to this question: Joining same table multiple times in ServiceStack.OrmLite
TableAlias
works with Select
, but not SelectMulti
.
Example:
var query = db.From<Department>(db.TableAlias("main"))
.Where(main => main.DepLevel == 3)
.Join<Department>((main, sub) => sub.DepParentNo == main.DepNo, db.TableAlias("sub"));
Now var rows = db.Select(query);
works, but this crashes:
var queryResults = db.SelectMulti<Department, Department>(query);
I've confirmed that when using db.Select
the LastCommandText
correctly aliases all three tables. However it probably doesn't do that with SelectMulti
.
The error message is as expected: The column prefix 'Department' does not match with a table name or alias name used in the query.
Upvotes: 2
Views: 150
Reputation: 1765
Answering my own question here:
There's an example in SS's source code:
AssertTupleResults(db.SelectMulti<Sale, ContactIssue, ContactIssue>(q,
new[] { "Sale.*", "buyer.*", "seller.*" }));
So the expression is now:
var queryResults = db.SelectMulti<Department, Department>(query,
new[] { "main.*", "sub.*" });
Upvotes: 2