public override bool ShouldCacheObject(SoodaObject theObject) { if (theObject.GetClassInfo().Cardinality == ClassCardinality.Small || theObject.GetClassInfo().Cardinality == ClassCardinality.Medium) return true; else return false; }
public override bool ShouldCacheObject(SoodaObject theObject) { if (theObject.GetClassInfo().Cardinality == ClassCardinality.Small || theObject.GetClassInfo().Cardinality == ClassCardinality.Medium) { return(true); } else { return(false); } }
void DoUpdates(SoodaObject obj, bool isPrecommit) { foreach (TableInfo table in obj.GetClassInfo().DatabaseTables) { DoUpdatesForTable(obj, table, isPrecommit); } }
protected internal void RegisterObject(SoodaObject o) { // Console.WriteLine("Registering object {0}...", o.GetObjectKey()); object pkValue = o.GetPrimaryKeyValue(); // Console.WriteLine("Adding key: " + o.GetObjectKey() + " of type " + o.GetType()); for (ClassInfo ci = o.GetClassInfo(); ci != null; ci = ci.InheritsFromClass) { AddObjectWithKey(ci.Name, pkValue, o); List <WeakSoodaObject> al; if (!_objectsByClass.TryGetValue(ci.Name, out al)) { al = new List <WeakSoodaObject>(); _objectsByClass[ci.Name] = al; } al.Add(new WeakSoodaObject(o)); } if (!UseWeakReferences) { _strongReferences.Add(o); } _objectList.Add(new WeakSoodaObject(o)); if (_precommitQueue != null) { _precommitQueue.Enqueue(o); } }
public override IDataReader LoadObjectTable(SoodaObject obj, object keyVal, int tableNumber, out TableInfo[] loadedTables) { ClassInfo classInfo = obj.GetClassInfo(); IDbCommand cmd = Connection.CreateCommand(); try { cmd.CommandTimeout = CommandTimeout; } catch (NotSupportedException e) { logger.Debug("CommandTimeout not supported. {0}", e.Message); } if (Transaction != null) { cmd.Transaction = this.Transaction; } SqlBuilder.BuildCommandWithParameters(cmd, false, GetLoadingSelectStatement(classInfo, classInfo.UnifiedTables[tableNumber], out loadedTables), SoodaTuple.GetValuesArray(keyVal), false); IDataReader reader = TimedExecuteReader(cmd); if (reader.Read()) { return(reader); } else { reader.Dispose(); return(null); } }
void DoDeletes(SoodaObject obj) { List <TableInfo> tables = obj.GetClassInfo().UnifiedTables; for (int i = tables.Count - 1; i >= 0; --i) { DoDeletesForTable(obj, tables[i]); } }
static int Compare(SoodaObject o1, SoodaObject o2) { int retval = string.CompareOrdinal(o1.GetClassInfo().Name, o2.GetClassInfo().Name); if (retval != 0) { return(retval); } return(((IComparable)o1.GetPrimaryKeyValue()).CompareTo(o2.GetPrimaryKeyValue())); }
protected internal void UnregisterObject(SoodaObject o) { object pkValue = o.GetPrimaryKeyValue(); if (ExistsObjectWithKey(o.GetClassInfo().Name, pkValue)) { UnregisterObjectWithKey(o.GetClassInfo().Name, pkValue); for (ClassInfo ci = o.GetClassInfo().InheritsFromClass; ci != null; ci = ci.InheritsFromClass) { UnregisterObjectWithKey(ci.Name, pkValue); } RemoveWeakSoodaObjectFromCollection(_objectList, o); List <WeakSoodaObject> al; if (_objectsByClass.TryGetValue(o.GetClassInfo().Name, out al)) { RemoveWeakSoodaObjectFromCollection(al, o); } } }
protected internal void RegisterDirtyObject(SoodaObject o) { // transactionLogger.Debug("RegisterDirtyObject({0})", o.GetObjectKeyString()); _dirtyObjects.Add(o); for (ClassInfo ci = o.GetClassInfo(); ci != null; ci = ci.InheritsFromClass) { List <WeakSoodaObject> al; if (!_dirtyObjectsByClass.TryGetValue(ci.Name, out al)) { al = new List <WeakSoodaObject>(); _dirtyObjectsByClass[ci.Name] = al; } al.Add(new WeakSoodaObject(o)); } }
void DoWithWhere(SoodaObject obj, StringBuilder builder, ArrayList queryParams, bool isRaw) { builder.Append(" where "); object primaryKeyValue = obj.GetPrimaryKeyValue(); FieldInfo[] primaryKeyFields = obj.GetClassInfo().GetPrimaryKeyFields(); for (int i = 0; i < primaryKeyFields.Length; i++) { if (i > 0) { builder.Append(" and "); } FieldEquals(primaryKeyFields[i], SoodaTuple.GetValue(primaryKeyValue, i), builder, queryParams); } SqlBuilder.BuildCommandWithParameters(_updateCommand, true, builder.ToString(), queryParams.ToArray(), isRaw); FlushUpdateCommand(false); }
public override object Evaluate(ISoqlEvaluateContext context) { object val; if (this.Path != null) { val = this.Path.Evaluate(context); } else { val = context.GetRootObject(); } if (val == null) { return(null); } SoodaObject so = (SoodaObject)val; return(so.GetClassInfo().Name); }
public override IDataReader LoadObjectTable(SoodaObject obj, object keyVal, int tableNumber, out TableInfo[] loadedTables) { ClassInfo classInfo = obj.GetClassInfo(); IDbCommand cmd = Connection.CreateCommand(); try { cmd.CommandTimeout = CommandTimeout; } catch(NotSupportedException e) { logger.Debug("CommandTimeout not supported. {0}", e.Message); } if (Transaction != null) cmd.Transaction = this.Transaction; SqlBuilder.BuildCommandWithParameters(cmd, false, GetLoadingSelectStatement(classInfo, classInfo.UnifiedTables[tableNumber], out loadedTables), SoodaTuple.GetValuesArray(keyVal), false); IDataReader reader = TimedExecuteReader(cmd); if (reader.Read()) return reader; else { reader.Dispose(); return null; } }
protected internal bool IsRegistered(SoodaObject o) { object pkValue = o.GetPrimaryKeyValue(); return(ExistsObjectWithKey(o.GetClassInfo().Name, pkValue)); }
void DoDeletes(SoodaObject obj) { List<TableInfo> tables = obj.GetClassInfo().UnifiedTables; for (int i = tables.Count - 1; i >= 0; --i) { DoDeletesForTable(obj, tables[i]); } }
void DoWithWhere(SoodaObject obj, StringBuilder builder, ArrayList queryParams, bool isRaw) { builder.Append(" where "); object primaryKeyValue = obj.GetPrimaryKeyValue(); FieldInfo[] primaryKeyFields = obj.GetClassInfo().GetPrimaryKeyFields(); for (int i = 0; i < primaryKeyFields.Length; i++) { if (i > 0) builder.Append(" and "); FieldEquals(primaryKeyFields[i], SoodaTuple.GetValue(primaryKeyValue, i), builder, queryParams); } SqlBuilder.BuildCommandWithParameters(_updateCommand, true, builder.ToString(), queryParams.ToArray(), isRaw); FlushUpdateCommand(false); }
internal void MarkPrecommitted(SoodaObject o) { _precommittedClassOrRelation[o.GetClassInfo().GetRootClass().Name] = true; }