我有一个TransactionData2ClassAction
子类,看起来像这样:
public class TransactionData2ClassAction : Entity
{
public int TransactionId => Get<int>();
public int FundId => Get<int>();
public string PortfolioCode => Get<string>();
public string SecuritySymbol => Get<string>();
public string SecurityTypeCode => Get<string>();
public DateTime TradeDate => Get<DateTime>();
public DateTime? SettleDate => Get<DateTime?>();
public decimal Quantity => Get<decimal>();
public decimal Amount => Get<decimal>();
public decimal SecFee => Get<decimal>();
public string BrokerCode => Get<string>();
public short TaxLotNumber => Get<short>();
public string TransactionCode => Get<string>();
public decimal CommissionAmount => Get<decimal>();
public int TestProperty { get; }
}
Entity
基类如下所示:
public class Entity : INotifyPropertyChanged, IDataErrorInfo
{
protected T Get<T>([CallerMemberName] string aColumnName = null, DataRowVersion? aDataRowVersion = null)
{
// Details.
}
protected string Get(CompressionEncryptionOptions aOption, [CallerMemberName] string aColumnName = null)
{
// Details.
}
}
我的问题是我该如何返回使用Entity
基类Get
方法之一的吸气剂的属性?
例如,结果将返回除TestProperty
之外的所有属性。
到目前为止,我已经拥有了:
public static PropertyInfo[] GetTransactionData2FieldsFromEntityUsingProperties(Type aEntityType)
{
if (!aEntityType.IsSubclassOf(typeof(Entity)))
throw new InvalidOperationException("Wrong type.");
return aEntityType.GetProperties().Where(aProperty => aProperty.CanRead && aProperty.GetAccessors().Any(aMethodInfo => aMethodInfo.IsAssembly || aMethodInfo.IsPublic)).ToArray();
}