Пример #1
0
 public void GetByWhereFirst()
 {
     using (var conn = DbHelper.GetConn())
     {
         PeopleTableOracle people = conn.GetByWhereFirst <PeopleTableOracle>("WHERE \"Id\"<:Id", new { Id = 4 });
         //PeopleTableOracle people = conn.GetByWhereFirst<PeopleTableOracle>("WHERE \"Id\"<:Id", new { Id = 4 },"\"Name\""); //only return [Name] field
         string json = JsonConvert.SerializeObject(people);
         Assert.Pass(json);
     }
 }
Пример #2
0
 public void GetById()
 {
     using (var conn = DbHelper.GetConn())
     {
         PeopleTableOracle people = conn.GetById <PeopleTableOracle>(1);
         //PeopleTableOracle people = conn.GetById<PeopleTableOracle>(1,"\"Name\""); //only return [name] field
         string json = JsonConvert.SerializeObject(people);
         Assert.Pass(json);
     }
 }
Пример #3
0
 public void InsertReturnId()
 {
     using (var conn = DbHelper.GetConn())
     {
         PeopleTableOracle people = new PeopleTableOracle();
         people.Name = "李四" + Second;
         people.Sex  = Second;
         var id = conn.InsertReturnIdForOracle(people, "seq_my");
         Assert.Pass(id.ToString());
     }
 }
Пример #4
0
 public void InsertIdentity()
 {
     using (var conn = DbHelper.GetConn())
     {
         PeopleTableOracle people = new PeopleTableOracle();
         people.Id   = 1;
         people.Name = "李四" + Second;
         people.Sex  = Second;
         int effect = conn.InsertIdentity(people);
         Assert.Pass(effect.ToString());
     }
 }
Пример #5
0
 public void Update()
 {
     using (var conn = DbHelper.GetConn())
     {
         PeopleTableOracle people = new PeopleTableOracle();
         people.Id   = 1;
         people.Name = "李四" + Second;
         people.Sex  = Second;
         int effect = conn.Update(people);
         //int effect = conn.Update(people, "Name"); //update people set Name=@Name where Id=@Id
         Assert.Pass(effect.ToString());
     }
 }
Пример #6
0
        public void UpdateByWhere()
        {
            using (var conn = DbHelper.GetConn())
            {
                PeopleTableOracle people = new PeopleTableOracle();
                people.Id   = 1;
                people.Name = "钱七" + Second;
                people.Sex  = 47;

                int effect = conn.UpdateByWhere(people, "WHERE \"Sex\"=:Sex", "Name");

                Assert.Pass(effect.ToString());
            }
        }
Пример #7
0
        public void Insert()
        {
            using (var conn = DbHelper.GetConn())
            {
                PeopleTableOracle people = new PeopleTableOracle();
                people.Id   = conn.GetSequenceNext <int>("seq_my");
                people.Name = "李四" + Second;
                people.Sex  = Second;
                int effect = conn.Insert(people);

                StudentTable student = new StudentTable();
                student.Id   = ObjectId.GenerateNewId().ToString();
                student.Name = "王五" + Second;
                student.Sex  = Second;
                effect      += conn.Insert(student);
                Assert.Pass(effect.ToString());
            }
        }
Пример #8
0
        public void InsertIdentityOrUpdate()
        {
            using (var conn = DbHelper.GetConn())
            {
                PeopleTableOracle people = new PeopleTableOracle();
                people.Id   = 1;
                people.Name = "王五" + Second;
                people.Sex  = Second;
                int effect = conn.InsertIdentityOrUpdate(people);

                PeopleTableOracle p2 = new PeopleTableOracle();
                p2.Id   = 52;
                p2.Name = "小罗" + Second;
                p2.Sex  = Second;
                effect += conn.InsertIdentityOrUpdate(p2);

                Assert.Pass(effect.ToString());
            }
        }
Пример #9
0
        public void InsertOrUpdate()
        {
            using (var conn = DbHelper.GetConn())
            {
                PeopleTableOracle people = new PeopleTableOracle();
                people.Id   = 1;
                people.Name = "王五" + Second;
                people.Sex  = Second;

                PeopleTableOracle p2 = new PeopleTableOracle();
                p2.Id   = 2;
                p2.Name = "王五" + Second;
                p2.Sex  = Second;

                int effect = conn.InsertOrUpdate(people);
                //int effect = conn.InsertOrUpdate(people, "Name"); //only update Name
                effect += conn.InsertOrUpdate(p2);

                Assert.Pass(effect.ToString());
            }
        }