No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.nuget
Sphiecoh.UniqueContraints.RavenDb
UniqueConstraints.RavenDb.Enforcer
README.md
Sphiecoh.UniqueContraints.RavenDb.sln

README.md

Sphiecoh.UniqueContraints.RavenDb

Add unique constraints your entities when using RavenDB.
Example usage :

var uniqueProperties = new RavenUniqueEnforcer<User>();
 uniqueProperties.AddProperty(x => x.Name);
 uniqueProperties.AddProperty(x => x.Email);
 
 using (var session = store.OpenSession())
				{
				   try
               {
					       //Should save
					        var user = new User() { Name = "John", Email = "john@gmail.com" };
                    new RavenUniqueInserter().StoreUnique(session,user, uniqueProperties);

                    //Should throw a UniqueConstraintViolationException exception 
                    var user1 = new User() { Name = "John", Email = "john@gmail.com" };
                    new RavenUniqueInserter().StoreUnique(session, user1, uniqueProperties);
                    }
                     catch (UniqueConstraintViolationException)
                    {
                        // email address and name already in use 
                    }
										
				}