SolvedPrivate

LINQ - Select + New Line

Posted on 2014-01-30
5
75 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 250 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 250 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

Containers and Docker for Everyone

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

Question has a verified solution.

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

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

688 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