SQL Azure and Sitecore Retryer

If you are deploying Sitecore on Azure and you are using SQL Azure, you should know that you could experience some connectivity issue between your Sitecore instance and your database…

Therefore it is strongly recommended to enable a retry mechanism on Sitecore data provider to recover these intermittent connectivity issues.

This is the default configuration that you will find in your web config, and what you need to do is to switch disabled to false….

you can either keep the logging enabled/disabled to log these connectivity issues and change the interval setting, but I would recommend to keep the default value…

<retryer disabled="true" type="Sitecore.Data.DataProviders.Retryer, Sitecore.Kernel">
      <param desc="Number of tries">6</param>
      <param desc="Interval between tries">00:00:00.500</param>
      <param desc="Log each exception (should be used for debug only)">true</param>
</retryer>
Advertisements

top X results in Dapper

For who does not know Dapper is a Micro-ORM

More specifically Dapper plays well to map SQL queries with strongly typed Classes and DapperParameters…

for the records, I am deeply in love with Dapper

const string SqlQuery = "select top (@top) * from Mytable "

using (var connection = OpenConnection())
{
return connection.Query<MyModel>(SqlQuery, new { top });
}

private IDbConnection OpenConnection()
{
var connection = new SqlConnection(_connectionString);
connection.Open();
return connection;
}

Sql tips

A few tips useful for your Sql Query…

Update with a join:

 UPDATE MyTable 
  SET Column = NewValue 
  FROM MyTable  INNER JOIN OtherTable ON MyTable.Key = OtherTable.Key 

trimming…
  select LTRIM(RTRIM(columnOne)) from table1 

select into
 
 SELECT Persons.LastName,Orders.OrderNo 
  INTO Backup 
  FROM Persons 
  INNER JOIN Orders  ON Persons.P_Id=Orders.P_Id