示例#1
0
        public void G11_TwoSequencesInTable()
        {
            Northwind    dbo = CreateDB();
            NorthwindG11 db  = new NorthwindG11(dbo.Connection);

            db.ExecuteCommand(@"create sequence rid_id1_seq");
            db.ExecuteCommand(@"create sequence rid_reanr_seq");
#if INGRES
            db.ExecuteCommand(@"create table Rid ( id int primary key DEFAULT rid_id1_seq.nextval, reanr int DEFAULT rid_reanr_seq.nextval)");
#else
            db.ExecuteCommand(@"create temp table Rid ( id int primary key DEFAULT nextval('rid_id1_seq'), reanr int DEFAULT nextval('rid_reanr_seq'))");
#endif
            DbLinq.Data.Linq.Table <NorthwindG11.Rid> Rids = db.GetTable <NorthwindG11.Rid>();

            var Rid = new NorthwindG11.Rid();
            Rid.Reanr = 22;
            Exception e = null;
            db.Rids.InsertOnSubmit(Rid);

            Rid       = new NorthwindG11.Rid();
            Rid.Reanr = 23;
            db.Rids.InsertOnSubmit(Rid);
            try
            {
                db.SubmitChanges();
            }
            catch (Exception ex)
            {
                e = ex;
            }
            db.ExecuteCommand("drop table rid");
            db.ExecuteCommand("drop sequence rid_reanr_seq");
            db.ExecuteCommand("drop sequence rid_id1_seq");
            if (e != null)
            {
                throw e;
            }
            Assert.AreEqual(2, Rid.Id);
            Assert.AreEqual(23, Rid.Reanr);
        }
示例#2
0
        public void G11_TwoSequencesInTable()
        {
            Northwind dbo = CreateDB();
            NorthwindG11 db = new NorthwindG11(dbo.Connection);

            db.ExecuteCommand(@"create sequence rid_id1_seq");
            db.ExecuteCommand(@"create sequence rid_reanr_seq");
#if INGRES
            db.ExecuteCommand(@"create table Rid ( id int primary key DEFAULT rid_id1_seq.nextval, reanr int DEFAULT rid_reanr_seq.nextval)");
#else
            db.ExecuteCommand(@"create temp table Rid ( id int primary key DEFAULT nextval('rid_id1_seq'), reanr int DEFAULT nextval('rid_reanr_seq'))");
#endif
            DbLinq.Data.Linq.Table<NorthwindG11.Rid> Rids = db.GetTable<NorthwindG11.Rid>();

            var Rid = new NorthwindG11.Rid();
            Rid.Reanr = 22;
            Exception e = null;
            db.Rids.InsertOnSubmit(Rid);

            Rid = new NorthwindG11.Rid();
            Rid.Reanr = 23;
            db.Rids.InsertOnSubmit(Rid);
            try
            {
                db.SubmitChanges();
            }
            catch (Exception ex)
            {
                e = ex;
            }
            db.ExecuteCommand("drop table rid");
            db.ExecuteCommand("drop sequence rid_reanr_seq");
            db.ExecuteCommand("drop sequence rid_id1_seq");
            if (e != null)
            {
                throw e;
            }
            Assert.AreEqual(2, Rid.Id);
            Assert.AreEqual(23, Rid.Reanr);
        }