Link to home
Start Free TrialLog in
Avatar of abenage
abenage

asked on

How can I store LINQ results in a session object

I have a simple LINQ query executing at page load whith which I would like to do two things.

A.  Concatenate two columns with a SPACE between such as:
               Select p.FirstName & " " & p.LastName as 'FullName'.  I can't get this to execute with LINQ.

B.  Store the returned record in a session object such as:
                session("FullName") = What I just retrieved from the DB

My query executes and I do get the returned individual columns.

Any ideas?
Dim db As New VBCODE.jhadbDataClassesDataContext
        Dim PersonName = From p In db.persons _
                         Where p.PersonID = Request("PersonID") _
                         Select p.FirstName, p.LastName

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Juan_Barrera
Juan_Barrera
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of abenage
abenage

ASKER

The problem I was having was that I was not passing my connectionstring.  I ended up using the string.concat method.

Thanks for your help.

        Dim db As New VBCODE.jhadbDataClassesDataContext(ConnString)
        Dim PersonName = From p In db.persons _
                         Where p.PersonID = Request("PersonID") _
                         Select Name = String.Concat(p.FirstName, " ", p.LastName)
        session("FullName") = PersonName.First

Open in new window