How to select multiple columns in one variable in entity framework code first?

Posted by Chetankhargone under ASP.NET on 7/8/2015 | Points: 10 | Views : 1591 | Status : [Member] | Replies : 2
I have two tables in sql (Singer, Albums) now my query is as below

IQuerable<AlbumVM> = (
from c in context.Singers
join d in context.Albums on c.SingerID equals d.SingerID
select new AlbumVM()
{
SingerName = c.SignerName,
AlbumsName = d.AlbumName
} );
Now suppose a singer has 50 columns,this query returns me 50 rows, then I need to iterate through it.

I feel I am missing something here. Is there someway in which I can get just one record as

SingerName , Albums[]
I am using Entity framework code-first.




Responses

Posted by: Bandi on: 7/10/2015 [Member] [MVP] Platinum | Points: 25

Up
0
Down
http://www.c-sharpcorner.com/UploadFile/ee01e6/how-to-get-comma-separated-values-from-sql-server-table-wit/

You can look into the above link to get the comma separated Album Names for each Singer.....

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Chetankhargone, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 7/10/2015 [Member] [MVP] Platinum | Points: 25

Up
0
Down
http://stackoverflow.com/questions/2861202/linq-query-with-subquery-as-comma-separated-values

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Chetankhargone, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response