2016-05-04 4 views

Antwort

3

Way 1

Eine einfache Art und Weise tun:

foreach (PXEventSubscriberAttribute attribute in cache.GetAttributes<Field>(dataRecord)) 
{ 
    PXSomeAttribute someAttribute = attribute as PXSomeAttribute; 
    if (someAttribute != null) 
    { 
     someAttribute.Property = someValue; 
    } 
} 

Way 2

Eine weniger ausführlich/wohl besser lesbar Art und Weise das gleiche Ziel mit LINQ zu erreichen:

cache 
    .GetAttributes<Field>(dataRecord) 
    .OfType<PXSomeAttribute>() 
    .ForEach(attribute => attribute.Property = someValue); 

Quelle: http://asiablog.acumatica.com/2016/05/dynamically-changing-attribute-property.html.

Verwandte Themen