Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 214893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:25:04+00:00 2026-05-11T18:25:04+00:00

I’ve had a look around on StackOverlow but haven’t been able to find a

  • 0

I’ve had a look around on StackOverlow but haven’t been able to find a definitive answer on this.

Below I have a code snippet of what I currently have, and I will explain what I am trying to achieve.

Table<Gallery> galleries = pdc.GetTable<Gallery>();
Table<GalleryImage> images = pdc.GetTable<GalleryImage>();
Table<Comment> comments = pdc.GetTable<Comment>();

var query = from gallery in galleries
            join image in images on gallery.id equals image.galleryid into joinedimages
            join comment in comments on gallery.id equals comment.galleryid into joinedcomments
            select gallery;

gallst.DataSource = query;
gallst.DataBind();

From the above I then have the following repeater:

<asp:Repeater ID="gallst" runat="server" EnableViewState="false">
    <HeaderTemplate>
        <div id="gallery">
    </HeaderTemplate>
    <ItemTemplate>
        <div class="item">
            <h2><%# DataBinder.Eval(Container.DataItem, "name") %> @ <%# DataBinder.Eval(Container.DataItem, "wheretaken") %></h2>
            <ul class="images">
            <asp:Repeater ID="galimgs" runat="server" EnableViewState="false" DataSource='<%# Eval("GalleryImages") %>'>
                <ItemTemplate>
                    <li><a href="<%# DataBinder.Eval(Container.DataItem, "image") %>.jpg" title="<%# DataBinder.Eval(((System.Web.UI.WebControls.RepeaterItem)Container.Parent.Parent).DataItem, "name") %>" rel="prettyPhoto[<%# DataBinder.Eval(Container.DataItem, "galleryid")%>]" class="thickbox"><img src="<%# DataBinder.Eval(Container.DataItem, "image") %>_thumb.jpg" /></a></li>
                </ItemTemplate>
            </asp:Repeater>
            </ul>
            <div class="comments">
            <asp:Repeater ID="galcomments" runat="server" EnableViewState="false" DataSource='<%# Eval("Comments") %>'>
                <HeaderTemplate>
                    <ul>
                </HeaderTemplate>
                <ItemTemplate>
                    <li><%# GetUserName(new Guid(Eval("userid").ToString())) %> said: <%#DataBinder.Eval(Container.DataItem, "comment1") %> (<%# DataBinder.Eval(Container.DataItem, "date", "{0:dddd  MM, yyyy hh:mm tt}") %>)</li>
                </ItemTemplate>
                <FooterTemplate>
                    </ul>
                </FooterTemplate>
            </asp:Repeater>
            <uc:makecomment ID="mcomment" runat="server" PhotoID='<%# DataBinder.Eval(Container.DataItem, "id") %>'></uc:makecomment>
        </div>
        </div>
    </ItemTemplate>
    <FooterTemplate>
        </div>
    </FooterTemplate>
</asp:Repeater>

What I want to do (ideally) is to only take the first 3 comments for each gallery.

I’ve tried the following LINQ Query with no luck:

var query = from gallery in galleries
            join image in images on gallery.id equals image.galleryid into joinedimages
            join comment in comments.Take(3) on gallery.id equals comment.galleryid into joinedcomments
            select gallery;

Does anyone have any suggestions on how I can achieve this?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T18:25:05+00:00Added an answer on May 11, 2026 at 6:25 pm

    I managed to get it to work with:

            Table<Gallery> galleries = pdc.GetTable<Gallery>();
            Table<GalleryImage> images = pdc.GetTable<GalleryImage>();
            Table<Comment> comments = pdc.GetTable<Comment>();
    
            var query = from gallery in galleries
                        join image in images on gallery.id equals image.galleryid into joinedimages
                        join comment in comments on gallery.id equals comment.galleryid into joinedcomments
                        select new
                        {
                            name = gallery.name,
                            wheretaken = gallery.wheretaken,
                            id = gallery.id,
                            GalleryImages = joinedimages,
                            Comments = joinedcomments.Take(3)
                        };
    
            gallst.DataSource = query;
            gallst.DataBind();
    

    With the take taken place on the select. Thanks for your help everyone. Any suggestions on how to write this “better” would be appreciated.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I used javascript for loading a picture on my website depending on which small
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.