• Status: Solved
  • Priority: Medium
  • Security: Private
  • Views: 86
  • 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 LeachProprietorCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

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