• Status: Solved
  • Priority: Medium
  • Security: Private
  • Views: 79
  • Last Modified:

LINQ - Select + New Line

Hi Experts!

In SQL you can do this to return a new line:

select Name + char(13) + Price
from dbo.Product

Open in new window


Is it possible in LINQ:

var data = from p in db.Products
            select new
            {
                   Name +  ??? +  Price
            };

Open in new window


TIA!
0
allanau20
Asked:
allanau20
  • 2
  • 2
2 Solutions
 
Ioannis ParaskevopoulosCommented:
var data = from p in db.Products
            select new
            {
                   Name +  System.Environment.NewLine+  Price
            };

Open in new window


Giannis
0
 
Jack LeachCommented:
Try this:

from blah in blah select "Name " + Environment.NewLine + "Price"
0
 
Ioannis ParaskevopoulosCommented:
To be more exact on my previous post:


var data = from p in db.Products
            select new
            {
                   result = p.Name +  System.Environment.NewLine+  p.Price
            };
                                            

Open in new window


Giannis
0
 
allanau20Author Commented:
very nice you guys; man .. I googled for half an hour and couldn't find the answer.
Thanks alot guys!
0
 
allanau20Author Commented:
perfect!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now