关键词:returning
返回所有列:returning *;
返回指定列:returning columnname;
删除命令不支持returning
参考代码:
string path = @"Data Source=D:\Data\data.sqlite;Version=3"; using (SQLiteConnection conn = new SQLiteConnection(path)) { conn.Open(); string sql = "insert into Table1 (`Column1`,`Column2`) values ('test', '123') returning *"; //sql = "select * from Table1"; sql = "update Table1 set `Column2`='12345' where `Column1`='test' returning *"; //sql = "delete from Table1 where `Column1`='test'"; //delete不支持returning using(SQLiteCommand cmd = conn.CreateCommand()) { cmd.CommandText = sql; using (var reader = cmd.ExecuteReader()) { while(reader.NextResult()) { } if (reader.Read() && reader.FieldCount > 0) { var a = reader[0]; DataTable dt = new DataTable(); dt.Load(reader); var list = dt.ToListModel<ClassA>(); ; } else { int records = reader.RecordsAffected; } } } }
标签:Sqlite,Table1,returning,C#,reader,插入,sql,var,using From: https://www.cnblogs.com/RedSky/p/18023240