I have created extension methods to map between objects but I am worried it may not be thread safe. Here is the method:
public static SavableRecord ToSavableRecordForMongoDB(this Record record)
{
SavableRecord savableRecord = new SavableRecord();
if (record.Fields == null)
throw new ArgumentException("Fields of record cannot be null");
if (string.IsNullOrWhiteSpace(record.id))
savableRecord._id = record.id;
foreach (KeyValuePair<string, Field> item in record.Fields)
savableRecord.Fields[item.Key] = new Field(item.Value);
return savableRecord;
}
If this method is not thread safe what can I do to make it thread safe.
Update
The record object is passed in the controller in an MVC project. The record object is never changed while in this controller or its path.