public ObservableCollection <AcquisitionBaseData> SelectBy(string _colname, string _value, bool _isdesc) { string connstr = "Data Source=ZNCPlatform.db;Version=3;"; var col = "ID";//默认为ID var sort = _isdesc ? "desc" : "asc"; if (_colname != "") { col = _colname; } var collection = new ObservableCollection <AcquisitionBaseData>(); var sql = "SELECT * FROM [AcquisitionBaseData] WHERE " + col + " = " + _value + " order by ID " + _isdesc; var conn = new SQLiteConnection(connstr); var ds = SqLiteHelper.ExecuteDataSet(conn, sql, null); if (ds != null && ds.Tables.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) { var resource = new AcquisitionBaseData(); resource.ID = int.Parse(dr["FloorID"].ToString()); resource.Code = int.Parse(dr["FloorName"].ToString()); resource.Confidence = int.Parse(dr["BuildingID"].ToString()); resource.Name = dr["Invalid"].ToString(); resource.Remark = dr["Remark"].ToString(); collection.Add(resource); } } return(collection); }
public void Test01() { var sSql = "Select * from Dicts where 1=1 and IsDeleted = '0'"; var aHelper = new SqLiteHelper(); var dsr = aHelper.ExecuteDataSet(_connString, sSql, CommandType.Text); object x = ""; Console.WriteLine(dsr.Tables.Count); }