Skip to content

Add ability to specify idbag (#415) #755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

jeff-hagen
Copy link
Contributor

@jeff-hagen jeff-hagen commented Aug 8, 2025

Closes #415

Adds the ability to specify a collection .AsIdBag(). Note that the NHibernate xml mapping model is a little odd:

  • The column attribute on collection-id is always required even though a column element can technically be specified.
  • The type attribute is required and must be a .net type (varchar will throw an exception)
  • The idbag is identical to the bag mapping, with the 2 exceptions:
    • The idbag has a collection-id element
    • The idbag doesn't have one-to-many

@jeff-hagen jeff-hagen changed the title Add ability to specify idbag (closes #415) Add ability to specify idbag (#415) Aug 8, 2025
@jeff-hagen
Copy link
Contributor Author

@hazzik would you mind taking a look at my PR?

@hazzik hazzik requested a review from Copilot August 20, 2025 04:11
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds the ability to specify an idbag collection type in FluentNHibernate mappings. Idbag is a type of collection mapping in NHibernate that combines characteristics of a bag with an identifier column for each row. The implementation includes mapping configuration, XML generation, and visitor pattern support.

  • Adds Collection.IdBag enum value and associated mapping infrastructure
  • Implements CollectionIdMapping class to configure the collection identifier
  • Adds AsIdBag() methods to fluent mapping API with configurable identifier type and generation strategy

Reviewed Changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
Collection.cs Adds IdBag enum value to collection types
CollectionMapping.cs Adds support for CollectionId property and IdBag factory method
CollectionIdMapping.cs New mapping class for collection identifier configuration
ToManyBase.cs Adds fluent AsIdBag() methods for configuring idbag collections
XmlIdBagWriter.cs New XML writer for generating idbag elements
XmlCollectionIdWriter.cs New XML writer for collection-id elements
XmlCollectionWriter.cs Updates collection writer to handle IdBag type
Visitor classes Adds support for visiting CollectionIdMapping
GeneratorBuilder.cs Refactors default generator logic into reusable method
CollectionIdPart.cs New fluent configuration class for collection identifiers
Test files Adds comprehensive tests for idbag functionality

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@jeff-hagen jeff-hagen requested a review from hazzik August 22, 2025 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for <idbag />
2 participants