private void EnsureStatment()
 {
     if (commandText == null)
     {
         throw new InvalidOperationException("must set CommandText");
     }
     if (template == null || template.OldSql != commandText)
     {
         lock (syncRoot)
         {
             if (!templates.TryGetValue(commandText, out template))
             {
                 if (IsNamed)
                 {
                     template = CreateNameTemplate();
                 }
                 else
                 {
                     template = CreateIndexTemplate();
                 }
                 templates.Add(commandText, template);
             }
         }
         CreateStatement();
     }
     else
     {
         statement.clearParameters();
     }
     for (int index = 0; index < template.Mapping.Length; ++index)
     {
         collection[template.Mapping[index]].SetStatement(index + 1, statement);
     }
 }