Пример #1
0
        public void SelectInSave()
        {
            var s1 = new ScheduleSelectInSave(1
                                              , "織田信長"
                                              , DateTime.Now
                                              , 160.34M
                                              , 50M
                                              , false
                                              , "天下布武"
                                              , new DateTime(1571, 9, 30, 00, 00, 0)
                                              , "叡山焼き討ち");

            using (var t1 = _db.CreateTran()) {
                Assert.That(t1.Save(s1), Is.EqualTo(1));
                Assert.That(t1.LastExecutedSql,
                            Is.EqualTo("INSERT INTO Schedules(id,date,subject)" +
                                       " VALUES(1,'1571-09-30'," + N + "'叡山焼き討ち')"));
            }

            var s2 = new ScheduleSelectInSave2(1
                                               , "織田信長"
                                               , new DateTime(2018, 6, 5)
                                               , 160.34M
                                               , 50M
                                               , false
                                               , "天下布武"
                                               , new DateTime(1571, 9, 30, 00, 00, 0)
                                               , "叡山焼き討ち");

            using (var t2 = _db.CreateTran()) {
                Assert.That(t2.Save(s2), Is.EqualTo(1));
                Assert.That(t2.LastExecutedSql,
                            Is.EqualTo("UPDATE Persons SET " +
                                       "name=" + N + "'織田信長',birthDay='2018-06-05',height=160.34," +
                                       "weight=50,isDaimyou=0,remarks=" + N + "'天下布武' " +
                                       "WHERE id=1"));
            }

            var s3 = new ScheduleSelectInSave3(1
                                               , "織田信長"
                                               , DateTime.Now
                                               , 160.34M
                                               , 50M
                                               , false
                                               , "天下布武"
                                               , new DateTime(1571, 9, 30, 00, 00, 0)
                                               , "叡山焼き討ち");

            using (var t3 = _db.CreateTran()) {
                Assert.That(t3.Save(s3), Is.EqualTo(1));
                Assert.That(t3.LastExecutedSql,
                            Is.EqualTo("UPDATE Schedules SET subject=" + N + "'叡山焼き討ち' " +
                                       "WHERE id=1 AND date='1571-09-30'"));
            }
        }
Пример #2
0
        public void SelectInSave()
        {
            var record = new ScheduleSelectInSave2(11
                                                   , "足利 義政"
                                                   , new DateTime(1436, 1, 20)
                                                   , 160
                                                   , null
                                                   , true
                                                   , "銀閣寺"
                                                   , new DateTime(1490, 1, 27)
                                                   , "崩御");

            using (var tran = _db.CreateTran()) {
                var i = tran.Save(record);
            }
        }
    public override bool Equals(object obj)
    {
        if (!(obj is ScheduleSelectInSave2))
        {
            return(false);
        }
        ScheduleSelectInSave2 schedule = (ScheduleSelectInSave2)obj;

        //HasValue=FalseなNull許容型同士を比較するとnullになるので、Trueになるように一致条件を工夫した
        if (this.Id == schedule.Id)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }