我需要生成一个ApplicantNumber
具有三个姓氏数字的数字,然后是具有该姓氏的人数。这是我的第一次尝试。我认为可序列化事务应该防止任何重复。会吗?
public string GenerateApplicantNumber(string surname)
{
using (new TransactionScope(TransactionScopeOption.RequiresNew, new TransactionOptions {IsolationLevel = IsolationLevel.Serializable}))
{
return string.Format("{0}{1}", surname.Substring(0, Math.Min(Regex.Replace(surname, @"\s+", "").Length, 3)),
_profileService.ReadApplicantProfiles().Count(p => !p.IsDeleted && p.LastName == surname));
}
}