//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void createConstraint(String label, String propertyKey) throws org.neo4j.internal.kernel.api.exceptions.KernelException
        private void CreateConstraint(string label, string propertyKey)
        {
            int        labelId;
            int        propertyKeyId;
            TokenWrite tokenWrite = TokenWriteInNewTransaction();

            labelId       = tokenWrite.LabelGetOrCreateForName(label);
            propertyKeyId = tokenWrite.PropertyKeyGetOrCreateForName(propertyKey);
            Commit();

            SchemaWrite schemaWrite = SchemaWriteInNewTransaction();

            schemaWrite.UniquePropertyConstraintCreate(forLabel(labelId, propertyKeyId));
            Commit();
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotBePossibleToCreateConstraintWithDuplicateProperties() throws org.neo4j.internal.kernel.api.exceptions.KernelException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotBePossibleToCreateConstraintWithDuplicateProperties()
        {
            // given
            SchemaWrite schemaWrite = SchemaWriteInNewTransaction();

            // when
            try
            {
                LabelSchemaDescriptor descriptor = forLabel(0, 1, 1);
                schemaWrite.UniquePropertyConstraintCreate(descriptor);
                fail("Should have failed");
            }
            catch (RepeatedPropertyInSchemaException)
            {
                // then good
            }
        }