This is a migrated thread and some comments may be shown as answers.

[Solved] Store mappings outside my app.config

2 Answers 204 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Chris
Top achievements
Rank 1
Chris asked on 21 Feb 2011, 12:47 AM
We have a fairly large database and thus a fairly large mappings xml block, and we want to store the <mappings> section outside of our web.config and reference this mappings file.

how can we accomplish this?

2 Answers, 1 is accepted

Sort by
0
IT-Als
Top achievements
Rank 1
answered on 21 Feb 2011, 10:52 AM
Hi Chris,

If you only want to store the class mappings (and not the connection settings, etc.) outside the web.config I guess the easiest way to do it is to create a class library holding your persistent classes and have an app.config in that class library to contain the mappings for the classes.
You can then reference the class library from your web app or another class library. I think it is good practice to do so.. in terms of separation of concerns..

Regards

Henrik
0
Serge
Telerik team
answered on 23 Feb 2011, 07:52 PM
Hello Chris,

 While what Henrik suggested is true, you can also just use a custom xml file with the contents. I have prepared a sample project that does exactly this. Basically I have instructed OpenAccess to use this file by modifying the ConfigFile project extension of the project, you can find it if you select the project in the solution explorer and click F4, this will pop up the property pane if it is not already visible. 

Also I have made this new config file an embedded resource and during runtime in the AdjustForDynamicLoad method I am passing the information to the Database.Get method. 

I should also point out that you are using the old wizards approach and if you were to give our new designer a try you will find out that the model information is by default kept in a separate file, an rlinq file. 

I hope this proves to be helpful and please do let us know if you face further trouble.

All the best,
Serge
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
General Discussions
Asked by
Chris
Top achievements
Rank 1
Answers by
IT-Als
Top achievements
Rank 1
Serge
Telerik team
Share this question
or