Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have SQL query:

select 
    Photo.[Path]
from 
    Album 
inner join 
    Photo on Album.AlbumId = Photo.AlbumId
where 
    Photo.PhotoId = (select top 1 Photo.PhotoId
                     from Photo 
                     where Photo.AlbumId = Album.AlbumId
                     order by NEWID() )

I want convert to linq to sql. I tried convert below:

var query = from a in db.Album
            join p in db.Photo on a.AlbumId equals p.AlbumId
            select new
                        {
                         photo.Path
                        };

But query below:

            where Photo.PhotoId=
            (
             select top 1 Photo.PhotoId
             from Photo 
            where Photo.AlbumId =Album.AlbumId
            order by NEWID()
)

--> I tried convert but do not success. I have spent all my energy on this. Please help me

Complete convert sql to linq to sql. Thank you very much everybody!

share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.