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 4111120
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:01:31+00:00 2026-05-20T22:01:31+00:00

i have 3 tables (Categories, Articles and ArticleCategories). The ArticleCategories has a combined PK

  • 0

i have 3 tables (Categories, Articles and ArticleCategories). The ArticleCategories has a combined PK and concists of:

  1. ArticleID (PK, FK, int)
  2. CategoryID (PK, FK, int)

Now when I’m using the subsonic paging methods I’m running into some very strange behaviour. It returns double the amount of records then I expect (the 2 PK’s?). The issue is resolved by either removing the paging completely or by adding a PK field called ArticleCategoryID.

        SubSonic.Query qry = new SubSonic.Query(DAL.ArticleCategory.Schema);
        qry.AddWhere(DAL.ArticleCategory.Columns.CategoryID, filterid);

        //Pagesize
        qry.PageSize = Classes.Settings.PageSizes.GetAdminPageSize();

        //Pageindex
        if (pageindex > 0)
            qry.PageIndex = pageindex;
        else
            qry.PageIndex = 1;

The above code works for all other tables but it fails with a many-to-many relationship. I could resort to adding the extra (and single) PK field but that doesn’t feel right.

Maybe I’m missing something obvious here so I apologize for that in advance 🙂

Thank you for your time
Kind regards,
Mark

  • 1 1 Answer
  • 0 Views
  • 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-20T22:01:32+00:00Added an answer on May 20, 2026 at 10:01 pm

    You may also read the answer of Rob Conery in this question – it’s about SubSonic 3, but since it says that Rob thinks a many-to-many table should have a single column primary key to identify uniquely a row in any table, I don’t think he implemented composite key support in SubSonic 2.

    I personally always add a PK column to many-to-many tables because it simplifies a lot of the CRUD code. Feels right to me – and if you are able to do so, I recommend to go for it.

    I couldn’t find the official documentation, but I also remember (and ran into problems…) that one should always use a PK column as the first column in a view, otherwise paging does not work correctly.

    The paging problem may also depend on the database version. The paging implementation with SQL Server 2000 for example is a hack (table variables etc) due to the lack of appropriate instructions in SQL Server. Later DB versions offer better ways to implement paging and may not depend on a single column PK.

    Last of all, not really about this question, and again a personal preference: I try to avoid SubSonic.Query and use SubSonic.SQLQuery instead. SqlQuery was added later on and is better than Query (see also this question)

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

Sidebar

Related Questions

I have 2 tables: Categories (int Id, string Title) Works (int categoryId, string WorkTitle,
I have 3 tables in my DB (MySQL). categories (name:string) items (name:string, category_id:int) votes
Let's assume I have a database with two tables: categories and articles . Every
I have 2 MySQL tables: categories (id int, name varchar(1000)) And products (id int,
Greetings - I have a table of Articles and a table of Categories. An
I have three tables: videos, videos_categories, and categories. The tables look like this: videos:
I have 3 tables (scenes, categories, scenes_categories ) in a many to many relationship.
I have 2 tables, Categories and Sub Categories. Is it prossible to present all
I have 4 tables: machines, categories, users and usersMAchines machines is linked to categories
I have three mysql tables, first holds information about articles (Article ID, author ID,

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.