public async Task IgnoreCase()
        {
            using (var conn = CreateConnection())
            {
                // 如果实体的 Schema 没有配置表名,则使用类名
                await conn.ExecuteAsync("drop table if exists test.dbo.IgnoreCase;");

                {
                    var storage = (RelationalDatabaseEntityStorageBase)CreateStorage(StorageMode.Insert);
                    storage.IgnoreCase = false;
                    var dfc      = new DataContext(null, null, null, null);
                    var typeName = typeof(CreateTableEntity7);
                    var entity   = new CreateTableEntity7();

                    var items = new List <CreateTableEntity7> {
                        entity
                    };
                    dfc.AddData(typeName, items);
                    await storage.HandleAsync(dfc);

                    var list = (await conn.QueryAsync <CreateTableEntity7>("SELECT * FROM test.dbo.IgnoreCase"))
                               .ToList();
                    Assert.Single(list);
                    entity = list.First();
                    Assert.Equal("xxx", entity.Str1);
                    Assert.Equal("yyy", entity.Str2);
                    Assert.Equal(655, entity.Required);
                    Assert.Equal(0, entity.Decimal);
                    Assert.Equal(600, entity.Long);
                    Assert.Equal(400, entity.Double);
                    Assert.Equal(200.0F, entity.Float);
                    await conn.ExecuteAsync("drop table if exists test.dbo.IgnoreCase;");
                }
            }
        }
Example #2
0
        public async Task IgnoreCase()
        {
            using (var conn = CreateConnection())
            {
                // 如果实体的 Schema 没有配置表名,则使用类名
                await conn.ExecuteAsync("drop table if exists test.dbo.IgnoreCase;");

                var services = SpiderProvider.Value.CreateScopeServiceProvider();
                var storage  = (RelationalDatabaseEntityStorageBase)CreateStorage(StorageType.Insert);
                storage.IgnoreCase = false;
                var dfc      = new DataFlowContext(null, services);
                var typeName = typeof(CreateTableEntity7).FullName;
                var entity   = new CreateTableEntity7();
                dfc.Add(typeName, entity.GetTableMetadata());
                var items = new ParseResult <CreateTableEntity7>
                {
                    entity
                };
                dfc.AddParseItem(typeName, items);
                await storage.HandleAsync(dfc);

                var list = (await conn.QueryAsync <CreateTableEntity7>("SELECT * FROM test.dbo.IgnoreCase")).ToList();
                Assert.Single(list);
                entity = list.First();
                Assert.Equal("xxx", entity.Str1);
                Assert.Equal("yyy", entity.Str2);
                Assert.Equal(655, entity.Required);
                Assert.Equal(0, entity.Decimal);
                Assert.Equal(600, entity.Long);
                Assert.Equal(400, entity.Double);
                Assert.Equal(200.0F, entity.Float);
                await conn.ExecuteAsync("drop table if exists test.dbo.IgnoreCase;");
            }
        }