public IdentifiedFactMemento GetIdentifiedMemento(FactID factId)
 {
     // Get the fact.
     _session.Command.CommandText = HEAD_SELECT +
                                    "WHERE f.FactID = @FactID " +
                                    TAIL_JOIN +
                                    "ORDER BY p.PredecessorID";
     AddParameter("@FactID", factId.key);
     using (var loader = new Loader(_session.Command.ExecuteReader()))
     {
         _session.Command.Parameters.Clear();
         return(loader.LoadMementos().FirstOrDefault());
     }
 }
        public List <IdentifiedFactMemento> GetEqualFactsByHashCode(FactMemento memento, bool readCommitted, int typeId)
        {
            _session.Command.CommandText = HEAD_SELECT +
                                           (readCommitted ? "" : "WITH (NOLOCK) ") +
                                           "WHERE f.FKTypeID = @TypeID AND f.Hashcode = @Hashcode " +
                                           TAIL_JOIN +
                                           "ORDER BY ff.FactID, p.PredecessorID";
            AddParameter("@TypeID", typeId);
            AddParameter("@Hashcode", memento.GetHashCode());
            using (var loader = new Loader(_session.Command.ExecuteReader()))
            {
                _session.Command.Parameters.Clear();

                return(loader.LoadMementos()
                       .Where(im => im.Memento.Equals(memento))
                       .ToList());
            }
        }
 public IdentifiedFactMemento GetIdentifiedMemento(FactID factId)
 {
     // Get the fact.
     _session.Command.CommandText = HEAD_SELECT +
         "WHERE f.FactID = @FactID " +
         TAIL_JOIN +
         "ORDER BY p.PredecessorID";
     AddParameter("@FactID", factId.key);
     using (var loader = new Loader(_session.Command.ExecuteReader()))
     {
         _session.Command.Parameters.Clear();
         return loader.LoadMementos().FirstOrDefault();
     }
 }
        public List<IdentifiedFactMemento> GetEqualFactsByHashCode(FactMemento memento, bool readCommitted, int typeId)
        {
            _session.Command.CommandText = HEAD_SELECT +
                (readCommitted ? "" : "WITH (NOLOCK) ") +
                "WHERE f.FKTypeID = @TypeID AND f.Hashcode = @Hashcode " +
                TAIL_JOIN +
                "ORDER BY ff.FactID, p.PredecessorID";
            AddParameter("@TypeID", typeId);
            AddParameter("@Hashcode", memento.GetHashCode());
            using (var loader = new Loader(_session.Command.ExecuteReader()))
            {
                _session.Command.Parameters.Clear();

                return loader.LoadMementos()
                    .Where(im => im.Memento.Equals(memento))
                    .ToList();
            }
        }