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

  • Home
  • SEARCH
  • 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 962559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:31:37+00:00 2026-05-16T01:31:37+00:00

I have a join table where the original table is a numeric type and

  • 0

I have a join table where the original table is a numeric type and the join table key column is a string type. Legacy decision that I am trying to avoid having to change to minimize the risk to the scope of work.

HasManyToMany<Attachment>(x => x.Attachments)
  .Table("ObjectAttachments")
  .ParentKeyColumn("ObjectId")
  .ChildKeyColumn("AttachmentId")
  .Fetch.Select()
  .LazyLoad()
  .AsBag();

The owning class uses a long (numeric) type for the identifier, while the join table uses a string type for the object identifier. How could I map this for it to change the data type on the fly? Is there something I can use to intercept and do the conversion?

Perhaps I can open up the discussion by providing a bit more background. The table relationship can be viewed as such:

Equipment -(r1)- ObjectAttachments -(r2)- Attachments

  • r1 is defined by Equipment.Id = ObjectAttachments.Object_Id AND ObjectAttachments.Class = ‘Equipment’
  • r2 is defined by ObjectAttachments.Attachment_Id = Attachment.Attachment_Id

The thing that is throwing me for a loop is Equipment.Id is an integer data type and ObjectAttachments.Object_Id is a string.

UPDATE: Here is how I have proceeded for now – I created a seperate repository for the attachments and created a map that brings in the join table. The repository requires that I convert the equipment identifier to a string. It’s not what I was hoping for but it works for now. Here’s what that map looks like:

Table("Attachments");
Id(x => x.Id);
Map(x => x.Name);
Map(x => x.Description);
Map(x => x.MimeType);
Map(x => x.Size);
Map(x => x.Date);
Map(x => x.Content).LazyLoad();
Join("ObjectAttachments", join =>
    {
        join.KeyColumn("Id");
        join.Map(x => x.ObjectId);
    });
  • 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-16T01:31:38+00:00Added an answer on May 16, 2026 at 1:31 am

    One solution would be to add an extra column to the table with the string id with a formula to return the string id cast to the correct numeric type.
    This constrains the problem with the database to the database rather than letting it bleed into the code.

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

Sidebar

Ask A Question

Stats

  • Questions 485k
  • Answers 485k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer F# does not allow for you to silently ignore return… May 16, 2026 at 7:42 am
  • Editorial Team
    Editorial Team added an answer kiamlaluno identified the basic problem, but to solve it, you're… May 16, 2026 at 7:42 am
  • Editorial Team
    Editorial Team added an answer A class's static initialization normally happens immediately before the first… May 16, 2026 at 7:42 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.