PlayerIO

The fastest way to build online games without breaking a sweat.

.NET Client Reference

Multiplayer  class documentationClass DatabaseObject

Namespace: PlayerIOClient
Language: C# / .NET

This class represents a BigDB Database Object that has a Key and a collection of named properties.

There are methods for setting, getting, and removing properties, and changes to the object can be persisted to BigDB with the Save() method.

Database objects are very similar to JSON objects and are most easily visualized as such. For example, we can visualize a car object like this:

If we then want to create this object in BigDB, we would have to do this:

To make it easier to work with nested objects, you can reference them directly by separating the property names with a dot. Using this, we can set the stats properties of the car like this instead:

When you want to read properties from a database object, you have to call the corresponding get method indicating the type of the property.

BigDB doesn't enforce anything on your objects. Two objects in the same table do not need to have the same properties set, and do not need to have the same type on the same property. If you try to get a property that is missing, or if you are using a get method of the wrong type, you will get an exception.

One way of avoiding this is to first check the object if a certain property exists before reading this. You can do this with the Contains method.

Another way of avoiding errors is to specify a default value when calling a get method. If the object doesn't contain the property, the method will return your default value instead.

You can also easily remove properties from your object with the Remove method.

Finally, to persist any changes you've made to an object you can call the Save method. Note that you can only call Save on an object that exist in the database. This means that the first time you save an object you have to call the PlayerIO.BigDB.CreateObject method, but all subsequent times you can call the Save method. There is also a property called ExistsInDatabase that you can use to check if it has been created or not.

The Save method is asynchronous just like the CreateObject method in PlayerIO.BigDB, and you can specify a callback if you wish to do something when the object actually has been saved.

Properties

 
public int
Count  [read-only]

Returns the number of properties on this object

public bool
ExistsInDatabase  [read-only]

Returns true if the object has been persisted

public string
Key  [read-only]

The key of the object.

public ICollection<string>
Properties  [read-only]

Get the names of all properties on this object

public string
Table  [read-only]

The name of the BigDB table this object belongs to

Methods

 
public void
Clear ()

Removes all properties on this object

public bool
Contains (string propertyExpression)

Returns true if the given property exists on this object

public DatabaseArray
GetArray (string propertyExpression)

Get the given array property

public bool
GetBool (string propertyExpression, bool defaultValue)

Get the given bool property, falling back to the given default value if the bool property does not exist

public bool
GetBool (string propertyExpression)

Get the given bool property

public Byte[]
GetBytes (string propertyExpression, Byte[] defaultValue)

Get the given byte array property, falling back to the given default value if the byte array property does not exist

public Byte[]
GetBytes (string propertyExpression)

Get the given byte array property

public DateTime
GetDateTime (string propertyExpression)

Get the given datetime property

public DateTime
GetDateTime (string propertyExpression, DateTime defaultValue)

Get the given datetime property, falling back to the given default value if the datetime property does not exist

public Double
GetDouble (string propertyExpression)

Get the given double property

public Double
GetDouble (string propertyExpression, Double defaultValue)

Get the given double property, falling back to the given default value if the double property does not exist

public Single
GetFloat (string propertyExpression, Single defaultValue)

Get the given float property, falling back to the given default value if the float property does not exist

public Single
GetFloat (string propertyExpression)

Get the given float property

public int
GetInt (string propertyExpression, int defaultValue)

Get the given int property, falling back to the given default value if the int property does not exist

public int
GetInt (string propertyExpression)

Get the given int property

public Int64
GetLong (string propertyExpression, Int64 defaultValue)

Get the given long property, falling back to the given default value if the long property does not exist

public Int64
GetLong (string propertyExpression)

Get the given long property

public DatabaseObject
GetObject (string propertyExpression)

Get the given object property

public string
GetString (string propertyExpression, string defaultValue)

Get the given string property, falling back to the given default value if the string property does not exist

public string
GetString (string propertyExpression)

Get the given string property

public uint
GetUInt (string propertyExpression, uint defaultValue)

Get the given uint property, falling back to the given default value if the uint property does not exist

public uint
GetUInt (string propertyExpression)

Get the given uint property

public object
GetValue (string propertyExpression)

Get the given property as an object

public DatabaseObject
Remove (string propertyExpression)

Removes the value of the given property from this object

public void
Save (Callback successCallback, Callback<PlayerIOError> errorCallback)

Persist the object to the database

public void
Save (Callback successCallback)

Persist the object to the database

public void
Save (bool useOptimisticLock)

Persist the object to the database, using optimistic locking if specified

public void
Save (bool useOptimisticLock, bool fullOverwrite)

Persist the object to the database, using optimistic locking and full overwrite if specified

public void
Save ()

Persist the object to the database

public void
Save (bool useOptimisticLock, bool fullOverwrite, Callback successCallback)

Persist the object to the database, using optimistic locking and full overwrite if specified

public void
Save (bool useOptimisticLock, Callback successCallback)

Persist the object to the database, using optimistic locking if specified

public void
Save (bool useOptimisticLock, Callback successCallback, Callback<PlayerIOError> errorCallback)

Persist the object to the database, using optimistic locking if specified

public void
Save (bool useOptimisticLock, bool fullOverwrite, Callback successCallback, Callback<PlayerIOError> errorCallback)

Persist the object to the database, using optimistic locking and full overwrite if specified

public DatabaseObject
Set (string propertyExpression, DatabaseObject value)

Set the given property to the given object

public DatabaseObject
Set (string propertyExpression, DatabaseArray value)

Set the given property to the given array

public DatabaseObject
Set (string propertyExpression, string value)

Set the given property to the given string value

public DatabaseObject
Set (string propertyExpression, DateTime value)

Set the given property to the given datetime value

public DatabaseObject
Set (string propertyExpression, Int64 value)

Set the given property to the given long value

public DatabaseObject
Set (string propertyExpression, uint value)

Set the given property to the given uint value

public DatabaseObject
Set (string propertyExpression, int value)

Set the given property to the given int value

public DatabaseObject
Set (string propertyExpression, bool value)

Set the given property to the given bool value

public DatabaseObject
Set (string propertyExpression, Byte[] value)

Set the given property to the given byte array value

public DatabaseObject
Set (string propertyExpression, Double value)

Set the given property to the given double value

public DatabaseObject
Set (string propertyExpression, Single value)

Set the given property to the given float value

DatabaseObject.Count

public int
Count  [read-only]

Returns the number of properties on this object

DatabaseObject.ExistsInDatabase

public bool
ExistsInDatabase  [read-only]

Returns true if the object has been persisted

DatabaseObject.Key

public string
Key  [read-only]

The key of the object.

DatabaseObject.Properties

public ICollection<string>
Properties  [read-only]

Get the names of all properties on this object

DatabaseObject.Table

public string
Table  [read-only]

The name of the BigDB table this object belongs to

DatabaseObject.Clear

public void
Clear ()

Removes all properties on this object

DatabaseObject.Contains

public bool
Contains (string propertyExpression)

Returns true if the given property exists on this object

Arguments

string propertyExpression

DatabaseObject.GetArray

public DatabaseArray
GetArray (string propertyExpression)

Get the given array property

Arguments

string propertyExpression

DatabaseObject.GetBool

public bool
GetBool (string propertyExpression, bool defaultValue)

Get the given bool property, falling back to the given default value if the bool property does not exist

Arguments

string propertyExpression
bool defaultValue

DatabaseObject.GetBool

public bool
GetBool (string propertyExpression)

Get the given bool property

Arguments

string propertyExpression

DatabaseObject.GetBytes

public Byte[]
GetBytes (string propertyExpression, Byte[] defaultValue)

Get the given byte array property, falling back to the given default value if the byte array property does not exist

Arguments

string propertyExpression
Byte[] defaultValue

DatabaseObject.GetBytes

public Byte[]
GetBytes (string propertyExpression)

Get the given byte array property

Arguments

string propertyExpression

DatabaseObject.GetDateTime

public DateTime
GetDateTime (string propertyExpression)

Get the given datetime property

Arguments

string propertyExpression

DatabaseObject.GetDateTime

public DateTime
GetDateTime (string propertyExpression, DateTime defaultValue)

Get the given datetime property, falling back to the given default value if the datetime property does not exist

Arguments

string propertyExpression
DateTime defaultValue

DatabaseObject.GetDouble

public Double
GetDouble (string propertyExpression)

Get the given double property

Arguments

string propertyExpression

DatabaseObject.GetDouble

public Double
GetDouble (string propertyExpression, Double defaultValue)

Get the given double property, falling back to the given default value if the double property does not exist

Arguments

string propertyExpression
Double defaultValue

DatabaseObject.GetFloat

public Single
GetFloat (string propertyExpression, Single defaultValue)

Get the given float property, falling back to the given default value if the float property does not exist

Arguments

string propertyExpression
Single defaultValue

DatabaseObject.GetFloat

public Single
GetFloat (string propertyExpression)

Get the given float property

Arguments

string propertyExpression

DatabaseObject.GetInt

public int
GetInt (string propertyExpression, int defaultValue)

Get the given int property, falling back to the given default value if the int property does not exist

Arguments

string propertyExpression
int defaultValue

DatabaseObject.GetInt

public int
GetInt (string propertyExpression)

Get the given int property

Arguments

string propertyExpression

DatabaseObject.GetLong

public Int64
GetLong (string propertyExpression, Int64 defaultValue)

Get the given long property, falling back to the given default value if the long property does not exist

Arguments

string propertyExpression
Int64 defaultValue

DatabaseObject.GetLong

public Int64
GetLong (string propertyExpression)

Get the given long property

Arguments

string propertyExpression

DatabaseObject.GetObject

public DatabaseObject
GetObject (string propertyExpression)

Get the given object property

Arguments

string propertyExpression

DatabaseObject.GetString

public string
GetString (string propertyExpression, string defaultValue)

Get the given string property, falling back to the given default value if the string property does not exist

Arguments

string propertyExpression
string defaultValue

DatabaseObject.GetString

public string
GetString (string propertyExpression)

Get the given string property

Arguments

string propertyExpression

DatabaseObject.GetUInt

public uint
GetUInt (string propertyExpression, uint defaultValue)

Get the given uint property, falling back to the given default value if the uint property does not exist

Arguments

string propertyExpression
uint defaultValue

DatabaseObject.GetUInt

public uint
GetUInt (string propertyExpression)

Get the given uint property

Arguments

string propertyExpression

DatabaseObject.GetValue

public object
GetValue (string propertyExpression)

Get the given property as an object

Arguments

string propertyExpression

DatabaseObject.Remove

public DatabaseObject
Remove (string propertyExpression)

Removes the value of the given property from this object

Arguments

string propertyExpression

DatabaseObject.Save

public void
Save (Callback successCallback, Callback<PlayerIOError> errorCallback)

Persist the object to the database

Arguments

Callback successCallback
Callback when the save succeeds
Callback<PlayerIOError> errorCallback
Callback that will be called instead of successCallback if an error occurs during the save.

DatabaseObject.Save

public void
Save (Callback successCallback)

Persist the object to the database

Arguments

Callback successCallback
Callback when the save succeeds

DatabaseObject.Save

public void
Save (bool useOptimisticLock)

Persist the object to the database, using optimistic locking if specified

Arguments

bool useOptimisticLock
If true, the save will only be completed if the database object has not changed in BigDB since this instance was loaded.

DatabaseObject.Save

public void
Save (bool useOptimisticLock, bool fullOverwrite)

Persist the object to the database, using optimistic locking and full overwrite if specified

Arguments

bool useOptimisticLock
If true, the save will only be completed if the database object has not changed in BigDB since this instance was loaded.
bool fullOverwrite
Will completely overwrite the database object in BigDB with the properties in this instance, instead of just sending the changed properties to the server.

DatabaseObject.Save

public void
Save ()

Persist the object to the database

DatabaseObject.Save

public void
Save (bool useOptimisticLock, bool fullOverwrite, Callback successCallback)

Persist the object to the database, using optimistic locking and full overwrite if specified

Arguments

bool useOptimisticLock
If true, the save will only be completed if the database object has not changed in BigDB since this instance was loaded.
bool fullOverwrite
Will completely overwrite the database object in BigDB with the properties in this instance, instead of just sending the changed properties to the server.
Callback successCallback
Callback when the save succeeds

DatabaseObject.Save

public void
Save (bool useOptimisticLock, Callback successCallback)

Persist the object to the database, using optimistic locking if specified

Arguments

bool useOptimisticLock
If true, the save will only be completed if the database object has not changed in BigDB since this instance was loaded.
Callback successCallback
Callback when the save succeeds

DatabaseObject.Save

public void
Save (bool useOptimisticLock, Callback successCallback, Callback<PlayerIOError> errorCallback)

Persist the object to the database, using optimistic locking if specified

Arguments

bool useOptimisticLock
If true, the save will only be completed if the database object has not changed in BigDB since this instance was loaded.
Callback successCallback
Callback when the save succeeds
Callback<PlayerIOError> errorCallback
Callback that will be called instead of successCallback if an error occurs during the save.

DatabaseObject.Save

public void
Save (bool useOptimisticLock, bool fullOverwrite, Callback successCallback, Callback<PlayerIOError> errorCallback)

Persist the object to the database, using optimistic locking and full overwrite if specified

Arguments

bool useOptimisticLock
If true, the save will only be completed if the database object has not changed in BigDB since this instance was loaded.
bool fullOverwrite
Will completely overwrite the database object in BigDB with the properties in this instance, instead of just sending the changed properties to the server.
Callback successCallback
Callback when the save succeeds
Callback<PlayerIOError> errorCallback
Callback that will be called instead of successCallback if an error occurs during the save.

DatabaseObject.Set

public DatabaseObject
Set (string propertyExpression, DatabaseObject value)

Set the given property to the given object

Arguments

string propertyExpression
DatabaseObject value

DatabaseObject.Set

public DatabaseObject
Set (string propertyExpression, DatabaseArray value)

Set the given property to the given array

Arguments

string propertyExpression
DatabaseArray value

DatabaseObject.Set

public DatabaseObject
Set (string propertyExpression, string value)

Set the given property to the given string value

Arguments

string propertyExpression
string value

DatabaseObject.Set

public DatabaseObject
Set (string propertyExpression, DateTime value)

Set the given property to the given datetime value

Arguments

string propertyExpression
DateTime value

DatabaseObject.Set

public DatabaseObject
Set (string propertyExpression, Int64 value)

Set the given property to the given long value

Arguments

string propertyExpression
Int64 value

DatabaseObject.Set

public DatabaseObject
Set (string propertyExpression, uint value)

Set the given property to the given uint value

Arguments

string propertyExpression
uint value

DatabaseObject.Set

public DatabaseObject
Set (string propertyExpression, int value)

Set the given property to the given int value

Arguments

string propertyExpression
int value

DatabaseObject.Set

public DatabaseObject
Set (string propertyExpression, bool value)

Set the given property to the given bool value

Arguments

string propertyExpression
bool value

DatabaseObject.Set

public DatabaseObject
Set (string propertyExpression, Byte[] value)

Set the given property to the given byte array value

Arguments

string propertyExpression
Byte[] value

DatabaseObject.Set

public DatabaseObject
Set (string propertyExpression, Double value)

Set the given property to the given double value

Arguments

string propertyExpression
Double value

DatabaseObject.Set

public DatabaseObject
Set (string propertyExpression, Single value)

Set the given property to the given float value

Arguments

string propertyExpression
Single value