tags:

views:

1452

answers:

1

Basically, it's the simple scenario of needing to populate a dropdown with LastName, FirstName by combining the two columns in the entity to FullName. I'd like it to live in the entity so I can grab it whenever I find a use for it. Is this possible?

+2  A: 

I would add a partial class that has the FullName property. Have a look at the designer file for your data context classes for the namespace and partial classname to use.

namespace your.namespace {

  public partial class yourclassname {
      public string FullName {
          get { return string.format("{0} {1}", FirstName, LastName); }
      }
  }

}
wulimaster
I believe this gave me some "not an updateable SQL something something" error when I tried this initially? I'll have to check again but it there's some trick to it?
EdenMachine
ah sweet - that worked. I swear I tried that before but I must have had some minor difference in mine. thanks!!!
EdenMachine
Only problem I have had is for a stored procedure result object....it will throw an error on those....something about a property without a setter. I believe you can "trick" those by decorating the partial class with a [Table] attribute.
wulimaster