Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            var sqliteDbPath = Path.Combine(Directory.GetCurrentDirectory(), "northwind.db");

            // configure ADO.NET and NReco.Data components
            var dbFactory = new DbFactory(Microsoft.Data.Sqlite.SqliteFactory.Instance)
            {
                LastInsertIdSelectText = "SELECT last_insert_rowid()"
            };
            var dbConnection = dbFactory.CreateConnection();

            dbConnection.ConnectionString = String.Format("Data Source={0}", sqliteDbPath);

            var dbCmdBuilder = new DbCommandBuilder(dbFactory);
            var dbAdapter    = new DbDataAdapter(dbConnection, dbCmdBuilder);

            // note: DbDataAdapter automatically opens (if it is not opened) and closes DB connection

            // lets remove all employees with ID>=1000 (cleanup)
            dbAdapter.Delete(new Query("Employees", (QField)"EmployeeID" >= (QConst)1000));

            // demo for select queries
            SelectDemo(dbAdapter);

            // demo for DbDataAdapter Insert/Update/Delete for one record
            InsertUpdateDeleteForOneRecord(dbAdapter);

            // demo for DbDataAdapter mass Update (record set)
            UpdateForRecordSet(dbAdapter);
        }
Ejemplo n.º 2
0
 public void Remove(int id)
 {
     _DbNRecoAdapter.Delete(
         new Query(
             "Articles",
             (QField)"Id" == (QConst)id
             )
         );
 }