Skip to content

v4.1.29

Compare
Choose a tag to compare
@noahjzc noahjzc released this 26 Sep 07:23
· 120 commits to master since this release

1. add support Auto Converter

configure for SmartSqlConfig.xml

  <AutoConverters>
    <AutoConverter Name="NoneConverter">
      <Tokenizer Name="None"/>
      <Converter Name="None"/>
    </AutoConverter>
    <AutoConverter Name="Default" Default="true">
      <Tokenizer Name="Default"/>
      <Converter Name="Pascal"/>      
    </AutoConverter>
    <AutoConverter Name="PascalConverter">
      <Tokenizer Name="Default">
        <Properties>
          <Property Name="IgnorePrefix" Value="" />
          <Property Name="Delimiter" Value="_" />
          <Property Name="UppercaseSplit" Value="false" />
        </Properties>
      </Tokenizer>
      <Converter Name="Pascal"/>
    </AutoConverter>
    <AutoConverter Name="DelimiterConverter">
      <Tokenizer Name="Default">
        <Properties>
          <Property Name="IgnorePrefix" Value="col_" />
          <Property Name="Delimiter" Value="_" />
          <Property Name="UppercaseSplit" Value="true" />
        </Properties>
      </Tokenizer>
      <Converter Name="Delimiter">
        <Properties>
          <Property Name="Prefix" Value="Col_" />
          <Property Name="Delimiter" Value="_"/>
          <Property Name="Mode" Value="FirstUpper"/>
        </Properties>
      </Converter>
    </AutoConverter>
  </AutoConverters>

configure for SqlMaps

    <!-- to current sql map -->
    <UseAutoConverter Name="DelimiterConverter"/>

    <!-- disabled auto converter to current sql map -->
    <UseAutoConverter Disabled="true"/>

    <!-- assign auto converter at statement -->
    <Statement Id="AssignAutoConverterQuery" AutoConverter="PascalConverter" >
        Select * From T_AutoConverter_1
    </Statement>

assign auto converter at RequestContext

            var list = SqlMapper.Query<AutoConverter_2>(new RequestContext
            {
                Scope = "DefaultAutoConverter",
                SqlId = "AssignAutoFromRequestConverterQuery",
                AutoConverterName = "DelimiterConverter"
            });