Include table alias inside object query

asked on June 1, 2021 11:13

Assuming that I need to join two tables, Table_A and Table_B, and that both tables contain column with the same name, for instance Reference_ID. If I want to retrieve the Reference_ID from Table_A, in the regular query I would just put an Alias to the Table_A and then retrieve the Reference_ID by specifying that alias (or the full table name).

How can I do this with Object Queries. The below query will throw an exception because it does not know which ReferenceNumber it is referring to.

ObjectQuery<CustomTableItem> items = CustomTableItemProvider
            .GetItems("Table_A").
            .Source(s =>
                        s.InnerJoin("Table_B", "TableID", "Table2ID"))
                .Columns("Reference_ID") // Here I want the ReferenceID from Table_A.
            .OrderBy(OrderBy);

Recent Answers


Jake Kula answered on June 1, 2021 20:49 (last edited on June 1, 2021 23:47)

Hi Michael,

You should be able to do this by referencing the column as: "Table_A.Reference_ID"

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.