Ninja Database Lite
KeyExists Method
Example 



KellermanSoftware.NinjaDatabaseLite Namespace > NinjaDb Class : KeyExists Method
Returns true if the key exists
Syntax
Public Function KeyExists( _
   ByVal key As String _
) As Boolean
Dim instance As NinjaDb
Dim key As String
Dim value As Boolean
 
value = instance.KeyExists(key)
public bool KeyExists( 
   string key
)
public:
bool KeyExists( 
   String^ key
) 

Parameters

key
Example
NinjaDbConfig config = new NinjaDbConfig();
string databasePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "MyApplication");
config.Storage = new FileDatabase(databasePath);
NinjaDb ninja = new NinjaDb(config);
 
Person person = new Person();
person.Name = "John";
person.PersonId = 1;
 
//Save
ninja.Save("Person1", person);
 
bool exists = ninja.KeyExists("Person1");
Dim config As New NinjaDbConfig()
Dim databasePath As String = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "MyApplication")
config.Storage = New FileDatabase(databasePath)
Dim ninja As New NinjaDb(config)
 
Dim person As New Person()
person.Name = "John"
person.PersonId = 1
 
'Save
ninja.Save("Person1", person)
 
Dim exists As Boolean = ninja.KeyExists("Person1")
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

NinjaDb Class
NinjaDb Members