コード例 #1
0
        public override void Close()
        {
            Commit();

            var lsession = GetSession();

            _objectWriter.FileSystemProcessor.WriteLastOdbCloseStatus(true, false);

            _objectWriter.FileSystemProcessor.Flush();
            if (lsession.TransactionIsPending())
            {
                throw new OdbRuntimeException(NDatabaseError.TransactionIsPending.AddParameter(lsession.GetId()));
            }

            IsDbClosed = true;
            ObjectReader.Close();
            _objectWriter.Close();

            lsession.Close();

            if (_objectIntrospector != null)
            {
                _objectIntrospector.Clear();
                _objectIntrospector = null;
            }

            // remove trigger manager
            RemoveLocalTriggerManager();
        }
コード例 #2
0
ファイル: Context.cs プロジェクト: tomtangrx/wilsonormapper
        private ObjectSet <T> GetObjectSet <T>(ObjectReader reader)
        {
            ObjectSet <T> objectSet = null;

            try {
                objectSet = new ObjectSet <T>(reader.PageIndex, reader.PageCount, reader.TotalCount);
                while (reader.Read())
                {
                    T      entityObject = (T)reader.Current();
                    object keyValue     = reader.ObjectKey();
                    objectSet.Add(keyValue, entityObject);
                }
            }
            catch (ORMapperException) {
                throw;
            }
            catch (Exception exception) {
                throw new ORMapperException("GetObjectSet<T> failed for " + reader.ObjectType.ToString(), exception);
            }
            finally {
                if (reader != null)
                {
                    reader.Close();
                }
            }
            return(objectSet);
        }
コード例 #3
0
ファイル: Context.cs プロジェクト: tomtangrx/wilsonormapper
 private System.Collections.ObjectModel.Collection <T> GetCollection <T>(ObjectReader reader)
 {
     System.Collections.ObjectModel.Collection <T> collection = new System.Collections.ObjectModel.Collection <T>();
     try {
         while (reader.Read())
         {
             collection.Add((T)reader.Current());
         }
     }
     finally {
         if (reader != null)
         {
             reader.Close();
         }
     }
     return(collection);
 }
コード例 #4
0
ファイル: Context.cs プロジェクト: tomtangrx/wilsonormapper
        private IList GetCollection(Type collectionType, ObjectReader reader)
        {
            IList collection = null;

            if (collectionType == typeof(ObjectSet))
            {
                collection = new ObjectSet(reader.ObjectType, reader.PageIndex, reader.PageCount, reader.TotalCount);
            }
            else if (collectionType == typeof(ObjectList))
            {
                ObjectSet objectSet = new ObjectSet(reader.ObjectType, reader.PageIndex, reader.PageCount, reader.TotalCount);
                collection = new ObjectList(this, objectSet);
            }
            else
            {
                collection = (IList)Activator.CreateInstance(collectionType, true);
            }

            try {
                while (reader.Read())
                {
                    if (collectionType == typeof(IObjectSet))
                    {
                        ((IObjectSet)collection).Add(reader.ObjectKey(), reader.Current());
                    }
                    else
                    {
                        collection.Add(reader.Current());
                    }
                }
            }
            finally {
                if (reader != null)
                {
                    reader.Close();
                }
            }
            return(collection);
        }