问题
water huang · 八月 17

如果通过表的字段找到实体类对应的属性

我想通过表面表里面的字段找到这个表对应的实体类的属性,有什么高效的方式吗?

实质的需求是,我查询一个表的时候,这个表的字段很多,我需要通过值定位到哪些字段符合。

产品版本: Ensemble 2016.1
$ZV: Cache for Windows (x86-64) 2016.2.3 (Build 907_11_20446U) Thu Nov 12 2020 16:56:45 EST
0
0 48
讨论 (2)1
登录或注册以继续

请在具体描述一下问题。

/// 系统工具,查询某个表的值所在的字段 Class User.PTFV Extends %Persistent [ Final ] { /// 表名 Property TbNme As %String(MAXLEN = ""); /// 字段名 Property FildNme As %String(MAXLEN = ""); /// 字段描述 Property FildDesc As %String(MAXLEN = ""); /// 值 Property Value As %String(MAXLEN = ""); /// 列序号 Property FildNo As %String; /// 表名-%id Property TbID As %String(MAXLEN = ""); ClassMethod Global(TbNme As %String = "", Condition As %String = "", StopSubscript As %String = "") As %Boolean [ SqlName = PTFV, SqlProc ] { s TbNme=$tr(TbNme,$c(0),"") q:TbNme="" $$$OK s:TbNme'["." TbNme="SQLUSER."_TbNme ;s:Condition'["'" Condition=$p(Condition,"=")_"='"_$p(Condition,"=",2)_"'" #dim val as %String = "" k ^||User.PTFVD s sql="SELECT %id As TbID,* FROM "_TbNme_" where "_Condition s rset=##class(%ResultSet).%New("%DynamicQuery:SQL") s sc=rset.Prepare(sql) s rset.RuntimeMode="1" i $$$ISERR(sc) { d DisplayError^%apiOBJ(sc) q $$$OK } s sc=rset.Execute() i $$$ISERR(sc) Do DisplayError^%apiOBJ(sc) q $$$OK While rset.Next(.sc) { s TbID=rset.Data("TbID") s FildNme="" f s FildNme=$o(rset.Data(FildNme)) q:FildNme="" d .q:FildNme="TbID" .s (FildDesc,Value,FildNo)="" .s Value=rset.Data(FildNme) .s ^||User.PTFVD($i(^||User.PTFVD))=$lb(TbNme,FildNme,FildDesc,Value,FildNo,TbID) } q $$$OK } Storage Default { TbNmeFildNmeFildDescValueFildNoTbID^||User.PTFVDPTFVDefaultData^||User.PTFVD^||User.PTFVI^||User.PTFVS%Library.CacheStorage } } 这个是的代码,我希望能得到 FildDesc和FildNo的值