/// <summary> /// Deletes data by the given primary key value. /// </summary> /// <param name="tableName">Name of the table.</param> /// <param name="primaryKeyValues">The primary key values.</param> /// <returns><c>true</c> if delete data success, <c>false</c> otherwise.</returns> public bool Delete(string tableName, params object[] primaryKeyValues) { try { if (database != null && primaryKeyValues != null) { using (IBox box = database.Cube()) { for (int i = 0, length = primaryKeyValues.Length; i < length; ++i) { object primaryKeyValue = primaryKeyValues[i]; box.Bind(tableName, primaryKeyValue).Delete(); } CommitResult result = box.Commit(); if (result.Equals(CommitResult.OK)) { return(true); } else { Debug.LogError(result.GetErrorMsg(box)); } } } } catch (Exception exception) { Debug.LogException(exception); } return(false); }
/// <summary> /// Updates data. /// </summary> /// <typeparam name="T">The type definition of data.</typeparam> /// <param name="tableName">Name of the table.</param> /// <param name="values">The list of data.</param> /// <returns><c>true</c> if update the list of data success, <c>false</c> otherwise.</returns> public bool Update <T>(string tableName, params T[] values) where T : class { try { if (database != null && values != null) { using (IBox box = database.Cube()) { for (int i = 0, length = values.Length; i < length; ++i) { T data = values[i]; box.Bind(tableName).Update <T>(data); } CommitResult result = box.Commit(); if (result.Equals(CommitResult.OK)) { return(true); } else { Debug.LogError(result.GetErrorMsg(box)); } } } } catch (Exception exception) { Debug.LogException(exception); } return(false); }