You have several options from Microsoft: ADO.NET or Linq2Sql are the popular ones at this time. But link you mentioned, it will take a good amount of work to convert from generating SQL to an ORM.
To make the creation of SQL more straight-forward and safer, you should consider using SQL Parameters. Here is an example:
using (SqlCommand saveCommand = DbUtil.CreateSqlCommand(context.Transaction)) {
saveCommand.CommandText =
"INSERT INTO Hit (" +
"Id, PersonId, TeamId, PlayerId" +
") VALUES (" +
"@Id, @PersonId, @TeamId, @PlayerId" +
")";
DbUtil.AddParameter(saveCommand, "@Id", SqlDbType.UniqueIdentifier, Guid.NewGuid());
DbUtil.AddParameter(saveCommand, "@PersonId", SqlDbType.UniqueIdentifier, hit.PersonId);
DbUtil.AddParameter(saveCommand, "@TeamId", SqlDbType.UniqueIdentifier, hit.TeamId);
DbUtil.AddParameter(saveCommand, "@PlayerId", SqlDbType.UniqueIdentifier, hit.PlayerId);
saveCommand.ExecuteNonQuery();
}
That will separate your parameter list from the SQL. Also the SQL we be much more legible. The DbUtil in the example is just a helper function I wrote to create my sql command from a connection or transaction. Also similar to your sqlh.addValue, I have a DbUtil.AddParameter that works by taking in the command, variable name, data type and value. Here's a sample including overloaded methods:
internal static SqlParameter CreateSqlParameter(
string parameterName,
SqlDbType dbType,
ParameterDirection direction,
object value
) {
SqlParameter parameter = new SqlParameter(parameterName, dbType);
if (value == null) {
value = DBNull.Value;
}
parameter.Value = value;
parameter.Direction = direction;
return parameter;
}
internal static SqlParameter AddParameter(
SqlCommand sqlCommand,
string parameterName,
SqlDbType dbType
) {
return AddParameter(sqlCommand, parameterName, dbType, null);
}
internal static SqlParameter AddParameter(
SqlCommand sqlCommand,
string parameterName,
SqlDbType dbType,
object value
) {
return AddParameter(sqlCommand, parameterName, dbType, ParameterDirection.Input, value);
}
internal static SqlParameter AddParameter(
SqlCommand sqlCommand,
string parameterName,
SqlDbType dbType,
ParameterDirection direction,
object value
) {
SqlParameter parameter = CreateSqlParameter(parameterName, dbType, direction, value);
sqlCommand.Parameters.Add(parameter);
return parameter;
}
internal static SqlParameter AddParameter(
SqlCommand sqlCommand,
string parameterName,
SqlDbType dbType,
ParameterDirection direction
) {
SqlParameter parameter = CreateSqlParameter(parameterName, dbType, direction, null);
sqlCommand.Parameters.Add(parameter);
return parameter;
}