コード例 #1
0
        /// <summary>
        /// 根据模式类型,查询ID类型和ID和时间点检索对象
        /// </summary>
        /// <param name="schemaType">表示模式类型的字符串</param>
        /// <param name="idType">表示ID类型的<see cref="SnapshotQueryIDType"/>值之一</param>
        /// <param name="id">对象的ID</param>
        /// <param name="timePoint"></param>
        /// <returns></returns>
        public SchemaObjectBase LoadByID(string schemaType, SnapshotQueryIDType idType, string id, DateTime timePoint)
        {
            schemaType.CheckStringIsNullOrEmpty("schemaType");
            id.CheckStringIsNullOrEmpty("id");

            SchemaDefine schema = SchemaDefine.GetSchema(schemaType);

            var timeConditon = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder(timePoint, "SN.");

            WhereSqlClauseBuilder whereBuilder = new WhereSqlClauseBuilder();

            EnumItemDescriptionAttribute attr = EnumItemDescriptionAttribute.GetAttribute(idType);

            whereBuilder.AppendItem("SN." + attr.ShortName, id);

            string sql = string.Format("SELECT SO.* FROM SC.SchemaObject SO INNER JOIN {0} SN ON SO.ID = SN.ID WHERE {1}",
                                       schema.SnapshotTable, new ConnectiveSqlClauseCollection(whereBuilder, timeConditon).ToSqlString(TSqlBuilder.Instance));

            DataTable table = DbHelper.RunSqlReturnDS(sql, this.GetConnectionName()).Tables[0];

            SchemaObjectBase result = null;

            if (table.Rows.Count > 0)
            {
                result = SchemaExtensions.CreateObject(schemaType);

                result.FromString((string)table.Rows[0]["Data"]);
                ORMapping.DataRowToObject(table.Rows[0], result);
            }

            return(result);
        }
コード例 #2
0
 /// <summary>
 /// 根据模式类型,查询ID类型和ID检索对象
 /// </summary>
 /// <param name="schemaType">表示模式类型的字符串</param>
 /// <param name="idType">表示ID类型的<see cref="SnapshotQueryIDType"/>值之一</param>
 /// <param name="id">对象的ID</param>
 /// <returns></returns>
 public SchemaObjectBase LoadByID(string schemaType, SnapshotQueryIDType idType, string id)
 {
     return(this.LoadByID(schemaType, idType, id, DateTime.MinValue));
 }