id

问题描述 投票:-1回答:1

我正在用C#在Dapper+Oracle中做测试。

样表如下

书籍

+----+----------------+-----------+
| id |     title      | author_id |
+----+----------------+-----------+
|  1 | this is a book |         2 |
+----+----------------+-----------+

撰稿人

+----+------+
| id | name |
+----+------+
|  2 | Mark |
+----+------+

我的代码。

string queryString = "SELECT distinct * FROM book b INNER JOIN author a ON a.id = b.author_id";
var result = connection.Query(queryString);

输出:

{DapperRow, id = 1, title='this is a book', author_id = 2, id = 2, name = 'Mark'}

结果中有两个字段的名字 "id "是重复的

我怎么能在重复的字段中添加别名或后缀,就像在sqldeveloper中的输出一样,就像下面这样

+----+----------------+-----------+------+------+
| id |     title      | author_id | id_1 | name |
+----+----------------+-----------+------+------+
|  1 | this is a book |         2 |    2 | Mark |
+----+----------------+-----------+------+------+

谢谢

c# oracle dapper
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.