我正在使用dapper Query方法通过左连接从sqlite获取一组数据,它确实返回了我需要但多次的列。
我在数据库浏览器上尝试了这些查询,效果很好,
string sql =
@"select a.id, a.alert_tag, lyr.layer_name, ln.line_name, t.task_name from alert_tag a
LEFT JOIN layer_group lyr on lyr.layerID = a.layer_group
LEFT JOIN line ln on ln.lineID = a.line
LEFT JOIN task t on t.taskID = a.task";
然后我称之为
using (IDbConnection cnn = new SQLiteConnection(Tools.LoadConnectionString()))
{
var output = cnn.Query<dynamic>(sql);
return output.ToList();
}
List<dynamic> Alerttag_List = new List<dynamic>();
private void LoadDGVdata()
{
Alerttag_List = SqliteQuery_AlertTagModel.Load();
dgv_AlertTag.DataSource = Alerttag_List;
}
我希望得到这样的结果
| id | alert_tag | layer_name | line_name | task_name |
但是我有这些
| id | alert_tag | layer_name | line_name | task_name | id | alert_tag | layer_name | line_name | task_name |