
Hello, has anyone here created a GetValue extension method for Entity? For example, consider the following scenario that sets a local variable to an entity attribute value:
string myVal;
if (myEntity.Attributes.Contains("new_myfield"))
myVal = account2011["new_myfield"];
An extension method could simplify this code to:
var myVal = myEntity.GetValue("new_myfield");
Seems logical to encapsulate this common code in an extension method. So has anyone here done this as part of an implementation?
*This post is locked for comments
I have the same question (0)Hi Andrew,
GetAttrbuteValue<T>("attributename") is available and also eliminates the use of "myEntity.Attributes.Contains("new_myfield")" line as it returns null instead of giving an error of key not present in disctionary.