コード例 #1
0
        public void Insert()
        {
            using (var dbContext = this.GlobalServiceProvider.GetRequiredService <SqliteDbContext>())
            {
                var testsInfo = new DbContextTestInfo
                {
                    Name       = Guid.NewGuid().ToString(),
                    Type       = InfoType.Black,
                    CreateTime = DateTime.Now
                };

                dbContext.Insert(testsInfo);

                Assert.True(testsInfo.Id > 0);
            }
        }
コード例 #2
0
        public void Select()
        {
            using (var dbContext = this.GlobalServiceProvider.GetRequiredService <SqliteDbContext>())
            {
                var testsInfo = new DbContextTestInfo
                {
                    Name       = Guid.NewGuid().ToString(),
                    Type       = InfoType.Black,
                    CreateTime = DateTime.Now
                };

                dbContext.Insert(testsInfo);

                var selectInfo = dbContext.SelectById(testsInfo.Id);

                Assert.NotNull(selectInfo);
                Assert.Equal(selectInfo.Name, testsInfo.Name);
            }
        }
コード例 #3
0
        public void Insert(DbContextTestInfo info)
        {
            var id = this.ExecuteScalar <int>(nameof(Insert), info);

            info.Id = id;
        }