public NuoDbDataAdapter(NuoDbDataAdapter other)
     : base()
 {
     this.SelectCommand = other.SelectCommand is ICloneable ? (NuoDbCommand)other.SelectCommand.Clone() : null;
     this.InsertCommand = other.InsertCommand is ICloneable ? (NuoDbCommand)other.InsertCommand.Clone() : null;
     this.DeleteCommand = other.DeleteCommand is ICloneable ? (NuoDbCommand)other.DeleteCommand.Clone() : null;
     this.UpdateCommand = other.UpdateCommand is ICloneable ? (NuoDbCommand)other.UpdateCommand.Clone() : null;
 }
 public NuoDbDataAdapter(NuoDbDataAdapter other)
     : base()
 {
     this.SelectCommand = other.SelectCommand is ICloneable ? (NuoDbCommand)other.SelectCommand.Clone() : null;
     this.InsertCommand = other.InsertCommand is ICloneable ? (NuoDbCommand)other.InsertCommand.Clone() : null;
     this.DeleteCommand = other.DeleteCommand is ICloneable ? (NuoDbCommand)other.DeleteCommand.Clone() : null;
     this.UpdateCommand = other.UpdateCommand is ICloneable ? (NuoDbCommand)other.UpdateCommand.Clone() : null;
 }
Example #3
0
        public void TestDisconnectedUpdate()
        {
            using (NuoDbConnection connection = new NuoDbConnection(connectionString))
            {
                DbDataAdapter da = new NuoDbDataAdapter("select id, number, name, position, team from hockey", connection);
                NuoDbCommandBuilder builder = new NuoDbCommandBuilder();
                builder.DataAdapter = da;
                DataTable dt = new DataTable();
                da.Fill(dt);

                DataRow row = dt.NewRow();
                row["NAME"] = "John Doe";
                row["POSITION"] = "Developer";
                row["TEAM"] = "NuoDB";
                row["NUMBER"] = 100;
                dt.Rows.Add(row);

                int changed = da.Update(dt);
                Assert.AreEqual(1, changed);

                // TODO: http://msdn.microsoft.com/en-us/library/ks9f57t0%28v=vs.80%29.aspx describes a few options
                // to retrieve the AutoNumber column. For the moment, I reload the entire table
                dt = new DataTable();
                da.Fill(dt);

                DataRow[] rows = dt.Select("NUMBER = 100");
                Assert.IsNotNull(rows);
                Assert.AreEqual(1, rows.Length);
                foreach (DataRow r in rows)
                    r["NUMBER"] = 0;
                changed = da.Update(dt);
                Assert.AreEqual(1, changed);

                rows = dt.Select("NUMBER = 0");
                Assert.IsNotNull(rows);
                Assert.AreEqual(1, rows.Length);
                foreach (DataRow r in rows)
                    r.Delete();
                changed = da.Update(dt);
                Assert.AreEqual(1, changed);

            }
        }
Example #4
0
        public void TestDisconnected()
        {
            using (NuoDbConnection connection = new NuoDbConnection(connectionString))
            {
                DataAdapter da = new NuoDbDataAdapter("select * from hockey", connection);
                DataSet ds = new DataSet();
                da.Fill(ds);
                foreach (DataRow r in ds.Tables[0].Rows)
                {
                    for (int i = 0; i < r.ItemArray.Length; i++)
                    {
                        if (i > 0)
                            Console.Out.Write(", ");
                        Console.Out.Write(r.ItemArray[i]);
                    } // for
                    Console.Out.WriteLine();
                } // foreach

                DataTable hockey = ds.Tables[0];
                var query = from player in hockey.AsEnumerable()
                            where player.Field<string>("Position") == "Fan"
                            select new
                            {
                                Name = player.Field<string>("Name")
                            };
                int count = 0;
                foreach (var item in query)
                {
                    Console.Out.Write(item.Name);
                    count++;
                }
                Assert.AreEqual(1, count);

            }
        }