Beispiel #1
0
        public void AutoUpdateFromRowDataObject()
        {
            Guid       g       = StopWatch.Start();
            SqlBuilder builder = SqlBuilder.Select().WithMetadata(true, SetupData.MetadataFileName)
                                 .From("Account")
                                 .AllColumns(false)
                                 .Where <decimal>("Account", "AccountID", SqlOperators.Equal, 526)
                                 .Builder;

            Console.WriteLine(builder.ToSql());
            ResultTable r = builder.Execute();

            Console.WriteLine(StopWatch.Stop(g, StopWatch.WatchTypes.Milliseconds, "1 Account selected in {0}ms"));
            g = StopWatch.Start();
            Assert.IsTrue(r.Count == 1, "Executed 1 account");
            RowData row = r.First();

            row.Column("Name", Guid.NewGuid().ToString());
            builder = SqlBuilder.Update().Update(row, new string[] { "AccountID", "Name" });
            Console.WriteLine(builder.ToSql());
            r = builder.Execute();
            Console.WriteLine(StopWatch.Stop(g, StopWatch.WatchTypes.Milliseconds, "1 Account updated in {0}ms"));
            row.AcceptChanges();
            Assert.IsTrue(r.First().Column <string>("Name") == row.Column <string>("Name"), "Names are equal");
            Assert.IsFalse(row.HasChanges, "The row does not have changes");
        }