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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:24:50+00:00 2026-06-17T16:24:50+00:00

I was wondering if it is possible to dynamically set the table mapping for

  • 0

I was wondering if it is possible to dynamically set the table mapping for the linq classes:

    [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.[Comfort 0601$Contact]")]
    public partial class Contact : INotifyPropertyChanging, INotifyPropertyChanged
    {
     ...

The reason I want to change this dynamically or programmatically is because the database I’m using is created by Navision. There the tables have a prefix of the company name to which these tables belong to. Therefor I would like to be able to change that prefix.

    [global::System.Data.Linq.Mapping.TableAttribute(Name = "dbo.["+SPResources.Database.Company+"$Contact]")]

whit Company as:

    public const string Company = "Comfort 0601";

I’ve tried this, but it only work if i declared Company as a constant.

The table structure between companies are identical. just the name & content change.

I hope someone can give some advice about this. I’m also not sure if it even is possible.

  • 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-06-17T16:24:52+00:00Added an answer on June 17, 2026 at 4:24 pm

    The answers of Brian and Gert are possible solutions for this problem. But changing the mapping at run-time is just not possible (as Brian mentioned).

    As our project progressed we decided that if we would need another company name (which would mean that that build is for a different customer) we would just rebuild the project. That decision made the following solution possible:

    We commented out the original mappings generated by Visual Studio:

    //[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.[Comfort 0601$Contact]")]
        public partial class Contact : INotifyPropertyChanging, INotifyPropertyChanged
        {
        ...
    

    Because we have our own partial class for every Linq class, we added the modified mapping at the top of our own class:

    [global::System.Data.Linq.Mapping.TableAttribute(Name = "dbo.["+SPResources.Database.Company+"$Contact]")]
    public partial class Contact
    {
    

    where our company will be:

    public const string Company = "Comfort 0601";
    

    If a rebuild is needed for a different company we simply change the Company variable.

    Note: This only works properly if you don’t change your *.dbml file in VS. If you do, VS will automatically undo your changes.

    Edit: As time has passed and I started to look more into the Entity Framework I found a more specific and suitable solution for this problem: http://www.codeproject.com/Articles/421643/How-to-Use-MVC-Net-on-the-Dynamics-NAV-Database-St

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

Sidebar

Related Questions

Just wondering if it is possible to dynamically create a list of strings in
I was wondering if it were possible to dynamically create an XML layout file
I'm wondering.. 1)is it possible to set an imageview's resource to the URL location
I'm wondering if at all it is possible to sandbox a dynamically linked library
I was wondering if using PreparedStatement.setString() was a good idea (possible, sensible?) to dynamically
I was wondering if it's possible to dynamically add subdomains that point to dynamic
I am wondering whether it is possible to add fields to objects dynamically. For
I am wondering if it is possible to get the real name of the
I was wondering if it was possible to dynamically inject a function parameter at
I'm wondering if it is possible to access a property of a class dynamically

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.