Comma seperated List In Linq query

Hi Team,

I have 2 tables,

SERVICEREQUEST  , QUOTATION

SERVICEREQUEST

SRN0      SRNAME            SRSATUS                               SRDATE
1            VMASI                     OPEN                            10/5/2015
2            RAM                            OPEN                              10/5/2015

QUOTATION

QNO      SRNO(fkEYFROM SERVICEREQUST Table)      qtn
1                                   1                                                                qt1
2                                   1                                                                qt2
3                                   1                                                                qt3
4                                   1                                                            qt4
5                                   2                                                                qt5
6                                   2                                                                qt6
7                                   2                                                                qt7

After Join two tables in LINQ query with comma sepearated output should be like this

Output  :

SRN0      SRNAME                   qtn
1              VAMSI               qt1,qt2,qt3,qt4
2              RAM               qt5,qt6,qt7



Can you please help me and give me query  to display above output in linq query

Thanks in advance
ganeahdevAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Fernando SotoRetiredCommented:
Hi ganeahdev;

Here is a Linq query that will do what you need.
// The database data context
TestDBEntities dbContext = new TestDBEntities();

// Getting the data from the database
var results = (from sr in dbContext.SERVICEREQUESTs
               join q in dbContext.QUOTATIONs on sr.SRNO equals q.SRNO into srGroup
               let qtrLst = srGroup.Select(q => q.qtn).ToList()
               select new
               {
                  SRNO = sr.SRNO,
                  SRNAME = sr.SRNAME,
                  qtr = qtrLst
               }).ToList().Select(newLst => new
                    { newLst.SRNO,
                      newLst.SRNAME,
                      qtrLst = string.Join(",", newLst.qtr)
                    }
               ).ToList();

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ganeahdevAuthor Commented:
nice answer and very useful also
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

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.