Ejemplo n.º 1
0
        public static void TestPropertyNameGeneration()
        {
            var ins = FastBulkInsertUtil.CreateBulkInserter <TestDbEntityWithoutAnnotations>(
                TableMappingRules.UpperSnake("MY_GEN_NAME"));

            Check.That(ins.TableName).Equals("MY_GEN_NAME");
            var f     = new Fixture();
            var ds    = f.CreateMany <TestDbEntityWithoutAnnotations>().ToArray();
            var instr = ins.BuildInstructionsForRows(ds);

            Check.That(instr).HasSize(4);
            Check.That(instr[0].DbParamType).Equals(DbParameterTypeNumbers.Raw);
            Check.That(instr[1].DbParamType).Equals(DbParameterTypeNumbers.NVarChar);
            Check.That(instr[2].DbParamType).Equals(DbParameterTypeNumbers.Date);
            // enum is number
            Check.That(instr[3].DbParamType).Equals(DbParameterTypeNumbers.Number);
        }
Ejemplo n.º 2
0
        public static void TestOwnPropertyRules()
        {
            var rules = new TableMappingRules
            {
                TableName           = "MY_TAB",
                ColumnNameGenerator = pi =>
                {
                    if (pi.Name == "MyString")
                    {
                        // strip this out
                        return(null);
                    }
                    var guessed = TableMappingRules.GuessColumnNameBasedOnPropertyInfo(pi);
                    return(guessed == "MY_DATE" ? "MY_CHANGED_DATE" : guessed);
                }
            };
            var ins =
                FastBulkInsertUtil.CreateBulkInserter <TestDbEntityWithoutAnnotations>(
                    rules);

            Check.That(ins.TableName).Equals("MY_TAB");
            Check.That(ins.Properties).HasSize(3);
            Check.That(ins.Properties[1].DbColumnName).Equals("MY_CHANGED_DATE");
        }