예제 #1
0
        public void IndexerWithSchemaIndex( )
        {
            // test should validate that both the PKey and an Index key exist in the schema
            // Fields[3] is the 'Surname' property and we will add an index on the field
            schema.Configure(f => f[3].Attributes |= Attribs.Index);
            var indexer = GetIndexer(schema);
            var pkey    = indexer.PKey;

            // test using ordinal number
            var srchKey = new DataValue(DataType.String, Attribs.Index).Value(3);

            Assert.IsTrue(indexer.TryGetIndex(srchKey, out IIndex idxSurname));
            Assert.AreEqual(3, idxSurname.Ordinal);

            // test using index name
            srchKey = srchKey.Value("Surname");

            Assert.IsTrue(indexer.TryGetIndex(srchKey, out idxSurname));
            Assert.AreEqual("Surname", idxSurname.Name);
        }