Results 1 to 2 of 2

Thread: Concat with Alias in LINQ to SQL

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2010
    Location
    San Marcos, TX
    Posts
    177

    Concat with Alias in LINQ to SQL

    Here's my SQL query:

    SELECT EmployeeID, EmployeeLastName + ', ' + EmployeeFirstName AS Name
    FROM employees
    ORDER BY Name

    How can I go about doing the samething in LINQ to SQL?

  2. #2
    Frenzied Member MattP's Avatar
    Join Date
    Dec 2008
    Location
    WY
    Posts
    1,227

    Re: Concat with Alias in LINQ to SQL

    Extend your Employee Linq class.

    Code:
    Partial Public Class Employee
    
        Public ReadOnly Property LastFirstName() As String
            Get
                Return FirstName & " " & LastName
            End Get
        End Property
    
    End Class
    Code:
            Dim employees = From e In ctx.Employees
                            Order By e.Name
                            Select e.EmployeeId, e.Name

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width