Reputation: 769
I am writing a WCF web service which allows to register new users in system. So I have the following operation contract:
[ServiceContract]
public interface ISecurityService
{
/// <summary>
/// Register new user in system, if no exceptions were thrown
/// user was registered successfully
/// </summary>
[OperationContract]
[FaultContract(typeof(SecurityFaultException))]
void Register(string userName, string password);
}
The idea is simple how to synchronize Register
method invocation to prevent registration of two users with the same names?
I thought about using IsolationLevel.Serializable
but I'm not sure about this solution. Can somebody give me a good advice or share some good practice about WCF services synchronization.
UPDATED: I save users in a database.
Upvotes: 0
Views: 709
Reputation: 13437
If you save users in db it's enough to use default Isolationlevel(ReadCommited) an just put a unique constraint or primary key in UserName column that prevent duplicate value.
Upvotes: 2