how can i pass parameter to linq query

Posted by girish on Stack Overflow See other posts from Stack Overflow or by girish
Published on 2010-05-01T09:30:02Z Indexed on 2010/05/01 9:37 UTC
Read the original article Hit count: 247

Filed under:

i want to pass parameter to linq query...

public IEnumerable GetPhotos()
{
    PhotoDBDataContext db = new PhotoDBDataContext();
    var tProduct = db.Photos;
    var query = from p in db.Photos
                orderby p.PhotoId descending
                select new { p.Album, p.AlbumId, p.Description, p.Photographer,
                             p.PhotographerId, p.PhotoId, p.Tags, p.Thumbnail,
                             p.Url };
    return query;
}

in above example "orderby p.PhotoId descending" is used, i want to use parameter in place of p.PhotoId

is it possible...

© Stack Overflow or respective owner

Related posts about linq-to-sql