Exemple #1
0
        public IEnumerable <ReferenceHistoryEntry> GetReferenceHistoryEntries(string objId)
        {
            ReferenceHistoryEntryCollection list = new ReferenceHistoryEntryCollection();

            WhereSqlClauseBuilder where1 = new WhereSqlClauseBuilder();

            where1.AppendItem("R.ObjectID", objId);

            WhereSqlClauseBuilder where2 = new WhereSqlClauseBuilder();

            where2.AppendItem("R.ParentID", objId);

            var sql = string.Format(@"SELECT R.[ParentID], R.[ObjectID], R.[VersionStartTime], R.[VersionEndTime], R.[Status], R.[IsDefault], R.[InnerSort], R.[CreatorID], R.[CreatorName],O.Name, O.DisplayName
FROM [SC].[SchemaRelationObjectsSnapshot] R LEFT JOIN SC.SchemaObjectSnapshot_Current O ON R.ParentID = O.ID
WHERE O.VersionStartTime <=R.VersionStartTime AND (O.VersionEndTime IS NULL OR O.VersionEndTime>=R.VersionEndTime) AND {0}
UNION
SELECT R.[ParentID], R.[ObjectID], R.[VersionStartTime], R.[VersionEndTime], R.[Status], R.[IsDefault], R.[InnerSort], R.[CreatorID], R.[CreatorName],O.Name, O.DisplayName
FROM [SC].[SchemaRelationObjectsSnapshot] R LEFT JOIN SC.SchemaObjectSnapshot_Current O ON R.ObjectID = O.ID
WHERE O.VersionStartTime <=R.VersionStartTime AND (O.VersionEndTime IS NULL OR O.VersionEndTime>=R.VersionEndTime) AND {1} ORDER BY VersionStartTime ASC
", where1.ToSqlString(TSqlBuilder.Instance), where2.ToSqlString(TSqlBuilder.Instance));

            using (var context = DbHelper.GetDBContext(this.GetConnectionName()))
            {
                Database db = DatabaseFactory.Create(context);

                var cmd = db.GetSqlStringCommand(sql);
                using (var dr = db.ExecuteReader(cmd))
                {
                    ORMapping.DataReaderToCollection(list, dr);
                }
            }

            return(list);
        }
		public IEnumerable<ReferenceHistoryEntry> GetReferenceHistoryEntries(string objId)
		{
			ReferenceHistoryEntryCollection list = new ReferenceHistoryEntryCollection();

			WhereSqlClauseBuilder where1 = new WhereSqlClauseBuilder();
			where1.AppendItem("R.ObjectID", objId);

			WhereSqlClauseBuilder where2 = new WhereSqlClauseBuilder();
			where2.AppendItem("R.ParentID", objId);

			var sql = string.Format(@"SELECT R.[ParentID], R.[ObjectID], R.[VersionStartTime], R.[VersionEndTime], R.[Status], R.[IsDefault], R.[InnerSort], R.[CreatorID], R.[CreatorName],O.Name, O.DisplayName
FROM [SC].[SchemaRelationObjectsSnapshot] R LEFT JOIN SC.SchemaObjectSnapshot_Current O ON R.ParentID = O.ID
WHERE O.VersionStartTime <=R.VersionStartTime AND (O.VersionEndTime IS NULL OR O.VersionEndTime>=R.VersionEndTime) AND {0}
UNION
SELECT R.[ParentID], R.[ObjectID], R.[VersionStartTime], R.[VersionEndTime], R.[Status], R.[IsDefault], R.[InnerSort], R.[CreatorID], R.[CreatorName],O.Name, O.DisplayName
FROM [SC].[SchemaRelationObjectsSnapshot] R LEFT JOIN SC.SchemaObjectSnapshot_Current O ON R.ObjectID = O.ID
WHERE O.VersionStartTime <=R.VersionStartTime AND (O.VersionEndTime IS NULL OR O.VersionEndTime>=R.VersionEndTime) AND {1} ORDER BY VersionStartTime ASC
", where1.ToSqlString(TSqlBuilder.Instance), where2.ToSqlString(TSqlBuilder.Instance));

			using (var context = DbHelper.GetDBContext(this.GetConnectionName()))
			{
				Database db = DatabaseFactory.Create(context);

				var cmd = db.GetSqlStringCommand(sql);
				using (var dr = db.ExecuteReader(cmd))
				{
					ORMapping.DataReaderToCollection(list, dr);
				}
			}

			return list;
		}