?
SolvedPrivate

LINQ - Select + New Line

Posted on 2014-01-30
5
Medium Priority
?
76 Views
Last Modified: 2016-02-10
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
Comment
Question by:allanau20
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 23

Accepted Solution

by:
Ioannis Paraskevopoulos earned 1000 total points
ID: 39823399
var data = from p in db.Products
            select new
            {
                   Name +  System.Environment.NewLine+  Price
            };

Open in new window


Giannis
0
 
LVL 4

Assisted Solution

by:Jack Leach
Jack Leach earned 1000 total points
ID: 39823400
Try this:

from blah in blah select "Name " + Environment.NewLine + "Price"
0
 
LVL 23

Expert Comment

by:Ioannis Paraskevopoulos
ID: 39823402
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
 
LVL 5

Author Comment

by:allanau20
ID: 39823461
very nice you guys; man .. I googled for half an hour and couldn't find the answer.
Thanks alot guys!
0
 
LVL 5

Author Closing Comment

by:allanau20
ID: 39823463
perfect!
0

Featured Post

Linux Academy Android App Now Supports Chromecast

We have some fantastic news for our Android fans. We’re so excited to announce that the Linux Academy Android app is now available with Chromecast support. That’s right – simply download the latest update of the Linux Academy App and start casting your favorite course videos!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question