Ninja Database Pro
IndexExists(Type,String) Method
Example 



KellermanSoftware.NinjaDatabasePro Namespace > NinjaDbPro Class > IndexExists Method : IndexExists(Type,String) Method
The type of the class
The name of the index, case sensitive
Returns true if the index exists for the passed in type and index name
Syntax
Public Overloads Function IndexExists( _
   ByVal type As Type, _
   ByVal indexName As String _
) As Boolean
Dim instance As NinjaDbPro
Dim type As Type
Dim indexName As String
Dim value As Boolean
 
value = instance.IndexExists(type, indexName)
public bool IndexExists( 
   Type type,
   string indexName
)
public:
bool IndexExists( 
   Type^ type,
   String^ indexName
) 

Parameters

type
The type of the class
indexName
The name of the index, case sensitive

Return Value

True if it exists
Example
NinjaDbPro db = new NinjaDbPro("MyDatabaseDirectory", "MyDatabaseName");
db.OpenDatabase();
 
//Add the index if it doesn't exist
if (!db.IndexExists(typeof(Person),"NameIndex"))
{
    db.AddIndex<Person>("NameIndex", "Name", IndexStyle.NonUnique);
}
 
bool indexExists = db.IndexExists(typeof(Person),"NameIndex");
 
db.CloseDatabase();
Dim db As New NinjaDbPro("MyDatabaseDirectory", "MyDatabaseName")
db.OpenDatabase()
 
'Add the index if it doesn't exist
If Not db.IndexExists(GetType(Person),"NameIndex") Then
    db.AddIndex(Of Person)("NameIndex", "Name", IndexStyle.NonUnique)
End If
 
Dim indexExists As Boolean = db.IndexExists(GetType(Person),"NameIndex")
 
db.CloseDatabase()
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

NinjaDbPro Class
NinjaDbPro Members
Overload List