Rashim's Blog

Archive for the ‘Linq’ Category

Say i have a Database table name Employee and has 4 columns like ID, Firstname, Lastname,Email etc. That is, there is no Fullname Column but we need it to display it on the UI. So what we usually do?
We fetch all data; iterate over the list of data to make the Fullname String, right?
But there is another nice way to do that, if we get the property Fullname like Firstname or Lastname then it might help us a lot for further processing.
What I did for that, I have an Employee class in my dbml file. So I have created a partial Class name Employee in which I have define a Property Fullname as read-only. So when we get the Object Employee we will get the property Fullname also.

public partial class Employee
    public string FullName
            return string.Format("{0} {1}", this.Firstname, this.LastName);

Very Simple but Handy !!!!!!

Blog Stats

  • 189,209 hits


%d bloggers like this: