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);
     }
 }
Ejemplo n.º 3
0
 void DoUpdates(SoodaObject obj, bool isPrecommit)
 {
     foreach (TableInfo table in obj.GetClassInfo().DatabaseTables)
     {
         DoUpdatesForTable(obj, table, isPrecommit);
     }
 }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
        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);
            }
        }
Ejemplo n.º 6
0
        void DoDeletes(SoodaObject obj)
        {
            List <TableInfo> tables = obj.GetClassInfo().UnifiedTables;

            for (int i = tables.Count - 1; i >= 0; --i)
            {
                DoDeletesForTable(obj, tables[i]);
            }
        }
Ejemplo n.º 7
0
        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()));
        }
Ejemplo n.º 8
0
        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);
                }
            }
        }
Ejemplo n.º 9
0
 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));
     }
 }
Ejemplo n.º 10
0
        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);
        }
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 12
0
        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;
            }
        }
Ejemplo n.º 13
0
        protected internal bool IsRegistered(SoodaObject o)
        {
            object pkValue = o.GetPrimaryKeyValue();

            return(ExistsObjectWithKey(o.GetClassInfo().Name, pkValue));
        }
Ejemplo n.º 14
0
 void DoUpdates(SoodaObject obj, bool isPrecommit)
 {
     foreach (TableInfo table in obj.GetClassInfo().DatabaseTables)
     {
         DoUpdatesForTable(obj, table, isPrecommit);
     }
 }
Ejemplo n.º 15
0
 void DoDeletes(SoodaObject obj)
 {
     List<TableInfo> tables = obj.GetClassInfo().UnifiedTables;
     for (int i = tables.Count - 1; i >= 0; --i)
     {
         DoDeletesForTable(obj, tables[i]);
     }
 }
Ejemplo n.º 16
0
 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);
 }
Ejemplo n.º 17
0
 internal void MarkPrecommitted(SoodaObject o)
 {
     _precommittedClassOrRelation[o.GetClassInfo().GetRootClass().Name] = true;
 }