public static object ExecuteScalar(this AnyDbConnection cnn, Select query, IDbTransaction transaction = null,
                                           int?commandTimeout = null)
        {
            string sql = GetSelectSql(cnn, query);

            if (!commandTimeout.HasValue)
            {
                commandTimeout = cnn.DefaultCommandTimeout;
            }
            DynamicParameters parameters = GetParameters(query.Query.CommandParams);

            return(cnn.ExecuteScalar(sql, parameters, transaction, commandTimeout, CommandType.Text));
        }
        public static long Execute(this AnyDbConnection cnn, Insert query, IDbTransaction transaction = null,
                                   int?commandTimeout = null)
        {
            string sql = GetInsertSql(cnn, query);

            if (!commandTimeout.HasValue)
            {
                commandTimeout = cnn.DefaultCommandTimeout;
            }
            DynamicParameters parameters = GetParameters(query.Query.CommandParams);
            bool returnIdentity          = !string.IsNullOrEmpty(query.Query.IdentityField);

            if (!returnIdentity)
            {
                return(Convert.ToInt64(cnn.Execute(sql, parameters, transaction, commandTimeout, CommandType.Text)));
            }
            return(Convert.ToInt64(cnn.ExecuteScalar(sql, parameters, transaction, commandTimeout, CommandType.Text)));
        }