entity getvalue extension method? RRS feed

  • Question

  • 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?
    Wednesday, May 14, 2014 12:07 AM

All replies