RichC
RichC

Reputation: 7879

Linq to SQL: combine two columns to make a readonly custom column

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?

Upvotes: 0

Views: 2282

Answers (1)

wulimaster
wulimaster

Reputation: 701

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); }
      }
  }

}

Upvotes: 2

Related Questions