public void Delete(IDbRef obj, bool inTran) { if (obj != null) { DbContext.Current.Database.Delete(obj, inTran); if (obj.HasCache) { var entity = (ISqliteEntity)obj.GetObject(); entity.IsTombstone = true; } } }
public void Delete(IDbRef obj, bool inTran) { using (SqliteTransaction tran = ActiveConnection.BeginTransaction()) { try { if (!inTran) { string tableName = obj.TableName; Exec(string.Format("DELETE FROM __{0} WHERE [Id]=@Id", tableName), cmd => { cmd.Transaction = tran; cmd.Parameters.AddWithValue("@Id", obj.ToString()); cmd.ExecuteNonQuery(); }); string q = string.Format("DELETE FROM {0} WHERE [Id]=@Id AND [TableName]=@TableName", TranStatusTable); Exec(q, cmd => { cmd.Transaction = tran; cmd.Parameters.AddWithValue("@Id", obj.ToString()); cmd.Parameters.AddWithValue("@TableName", tableName); cmd.ExecuteNonQuery(); }); } else { lock (_dbsync) CopyTranObject(tran, obj.TableName, obj.ToString(), Operation.Delete); } Exec(string.Format("UPDATE [_{0}] SET IsTombstone = 1 WHERE [Id]=@Id", obj.TableName), cmd => { cmd.Transaction = tran; cmd.Parameters.AddWithValue("@Id", obj.ToString()); cmd.ExecuteNonQuery(); }); tran.Commit(); } catch { tran.Rollback(); } } }
public static IDictionary <string, object> GetConstants(XmlDocument doc) { var result = CustomDictionaryFactory(); XmlNodeList nodes = doc.DocumentElement.SelectNodes("//Configuration/Constants/Entity"); foreach (XmlNode node in nodes) { string entityName = node.Attributes["Name"].Value; var constant = CustomDictionaryFactory(); result.Add(entityName.Split('.')[1], constant); XmlNodeList rows = node.SelectNodes("Row"); foreach (XmlNode row in rows) { string name = row.Attributes["Name"].Value.Replace(' ', '_'); var id = new Guid(row.Attributes["Id"].Value); IDbRef dbRef = DbRefFactory(entityName.Replace('.', '_'), id); constant.Add(name, dbRef); } } return(result); }
public void Delete(IDbRef obj, bool inTran) { using (SqliteTransaction tran = ActiveConnection.BeginTransaction()) { try { using (var cmd = new SqliteCommand(String.Format("UPDATE [_{0}] SET IsTombstone = 1 WHERE [Id]=@Id", obj.TableName), tran.Connection, tran)) { cmd.Parameters.AddWithValue("@Id", obj.ToString()); cmd.ExecuteNonQuery(); } if (!inTran) { String tableName = obj.TableName; using (var cmd = new SqliteCommand(String.Format("DELETE FROM __{0} WHERE [Id]=@Id", tableName), tran.Connection, tran)) { cmd.Parameters.AddWithValue("@Id", obj.ToString()); cmd.ExecuteNonQuery(); } using (var cmd = new SqliteCommand(String.Format("DELETE FROM {0} WHERE [Id]=@Id AND [TableName]=@TableName", TranStatusTable), tran.Connection, tran)) { cmd.Parameters.AddWithValue("@Id", obj.ToString()); cmd.Parameters.AddWithValue("@TableName", tableName); cmd.ExecuteNonQuery(); } } tran.Commit(); } catch { tran.Rollback(); } } }
public void Delete(IDbRef obj) { Delete(obj, true); }