Ejemplo n.º 1
0
        private SoodaObject LoadObject(ISoodaObjectFactory factory, string keyString)
        {
            object      keyValue = factory.GetPrimaryKeyFieldHandler().RawDeserialize(keyString) ?? string.Empty;
            SoodaObject obj      = factory.GetRef(this, keyValue);

            obj.LoadAllData();
            return(obj);
        }
Ejemplo n.º 2
0
        static SoodaObject GetRefFromRecordHelper(SoodaTransaction tran, ISoodaObjectFactory factory, IDataRecord record, int firstColumnIndex, TableInfo[] loadedTables, int tableIndex, bool loadData)
        {
            object keyValue;
            Sooda.Schema.FieldInfo[] pkFields = factory.GetClassInfo().GetPrimaryKeyFields();
            if (pkFields.Length == 1)
            {
                int pkFieldOrdinal = loadData ? firstColumnIndex + pkFields[0].OrdinalInTable : 0;
                try
                {
                    keyValue = factory.GetPrimaryKeyFieldHandler().RawRead(record, pkFieldOrdinal);
                }
                catch (Exception ex)
                {
                    logger.Error("Error while reading field {0}.{1}: {2}", factory.GetClassInfo().Name, pkFieldOrdinal, ex);
                    throw ex;
                }
            }
            else
            {
                object[] pkParts = new object[pkFields.Length];
                for (int currentPkPart = 0; currentPkPart < pkFields.Length; currentPkPart++)
                {
                    int pkFieldOrdinal = loadData ? firstColumnIndex + pkFields[currentPkPart].OrdinalInTable : currentPkPart;
                    SoodaFieldHandler handler = factory.GetFieldHandler(pkFieldOrdinal);
                    pkParts[currentPkPart] = handler.RawRead(record, pkFieldOrdinal);
                }
                keyValue = new SoodaTuple(pkParts);
                //logger.Debug("Tuple: {0}", keyValue);
            }

            SoodaObject retVal = factory.TryGet(tran, keyValue);
            if (retVal != null)
            {
                if (loadData && !retVal.IsDataLoaded(0))
                    retVal.LoadDataFromRecord(record, firstColumnIndex, loadedTables, tableIndex);
                return retVal;
            }

            factory = GetFactoryFromRecord(tran, factory, record, firstColumnIndex, keyValue, loadData);
            retVal = factory.GetRawObject(tran);
            tran.Statistics.RegisterObjectUpdate();
            SoodaStatistics.Global.RegisterObjectUpdate();
            retVal.InsertMode = false;
            retVal.SetPrimaryKeyValue(keyValue);
            if (loadData)
                retVal.LoadDataFromRecord(record, firstColumnIndex, loadedTables, tableIndex);
            return retVal;
        }
Ejemplo n.º 3
0
 private SoodaObject LoadObject(ISoodaObjectFactory factory, string keyString)
 {
     object keyValue = factory.GetPrimaryKeyFieldHandler().RawDeserialize(keyString) ?? string.Empty;
     SoodaObject obj = factory.GetRef(this, keyValue);
     obj.LoadAllData();
     return obj;
 }
Ejemplo n.º 4
0
 private SoodaObject GetObject(ISoodaObjectFactory factory, string keyString)
 {
     object keyValue = factory.GetPrimaryKeyFieldHandler().RawDeserialize(keyString) ?? string.Empty;
     return factory.GetRef(this, keyValue);
 }
Ejemplo n.º 5
0
        private SoodaObject GetObject(ISoodaObjectFactory factory, string keyString)
        {
            object keyValue = factory.GetPrimaryKeyFieldHandler().RawDeserialize(keyString) ?? string.Empty;

            return(factory.GetRef(this, keyValue));
        }