SolvedPrivate

LINQ - Select + New Line

Posted on 2014-01-30
5
73 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
  • 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
defining NULL or 0 10 44
Very Large data in MYSQL 7 76
SSRS 2016 Rendering HTML tables 3 31
Comparison query - 4 columns 9 28
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

808 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