I removed the [ and ] where they are at the moment and did this but there's no doubt some better way:
private string _TableName;
public string TableName {
get { return _TableName; }
set
{
if(value.StartsWith("[") || value.EndsWith("]") || value.Contains("."))
{
_TableName = value;
}
else
{
_TableName= "[" + value + "]";
}
}
}
As I didn't want to do the mappings by hand as my columns and properties were consistent I added this so that I didn't have to do any mapping. Wondered if it might be a helpful addition
/// <summary>
/// Use this method to auto map by column name
/// </summary>
/// <returns></returns>
public MapperBuilder<T> AutoMapping()
{
foreach (PropertyInfo property in typeof(T).GetProperties())
{
_mapper.Mappings.Add(property.Name, property.Name);
}
return this;
}