第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

通過屬性名稱獲取通用代碼中的value / obj ref

通過屬性名稱獲取通用代碼中的value / obj ref

C#
慕妹3146593 2021-05-02 20:16:17
我最近創(chuàng)建了通用sql命令生成代碼。一切正常,但我目前正在努力解決的一件事。如何通過給定的屬性名稱獲取實例/ Answer屬性的值?是)我有的:問題實例作為對象(例如myObject)問題的屬性+內(nèi)部道具名稱(字符串)+內(nèi)部類類型[Table("Question")]public class Question{    [Column("QuestionID", true)]    public int QuestionId { get; set; }    [Column("Number")]    public string Nr { get; set; }    [Column("CorrectAnswer", typeof(Answer), nameof(Answer.Text))]    public Answer CorrectAnswer { get; set; }}[AttributeUsage(AttributeTargets.Property, Inherited = false)]public class ColumnAttribute : DatabaseAttribute{    public bool IsTechnicalId { get; private set; } = false;    public string DeepPropName { get; private set; } = null;    public Type DeepClass { get; private set; } = null;    public bool HasDeepProp { get; private set; } = false;    public ColumnAttribute(string name) : base(name)    {    }    /// <summary>    /// Creates a deep object property column definition    /// </summary>    /// <param name="name"></param>    /// <param name="deepProperty"></param>    public ColumnAttribute(string name, Type deepClass, string deepPropertyName) : base(name)    {        DeepPropName = deepPropertyName;        DeepClass = deepClass;        HasDeepProp = true;    }    public ColumnAttribute(string name, bool isTechnicalId) : this(name)    {        IsTechnicalId = isTechnicalId;    }}我當(dāng)前用于獲取道具和值的代碼如下所示。   一切都可以正常運行,唯一的例外是:如何獲取要搜索的對象內(nèi)另一個對象的屬性值?我可以獲取實例對象屬性的任何實例嗎?Edit1:我可以通過if(pInfo.Name == "CorrectAnswer")    answerRef = pInfo.GetValue(obj, null);然后從answerRef角色獲取道具,以獲取給定propName的值
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 160 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號