The code you provided in the above thread updates the Database to match the Project Model.
string ddlScript = handler.CreateUpdateDDLScript(null);
How do I update my rlinq to match the database I am connecting to at runtime?
check for new tables/columns in the database and update the rlinq at runtime to include those new items.
5 Answers, 1 is accepted
While you are able to define artificial types without them being presented in your rlinq Domain Model at design time, unfortunately reading additional tables at runtime is not possible with the current release of OpenAccess ORM. We will be glad if you can share your scenario that requires such functionality - maybe we will be able to provide another solution?
I am looking forward to your feedback.
the Telerik team
So which is it?
I am sorry for the misunderstanding. Let me clarify what is supported and what is not:
- You can create classes and properties during runtime and define the mapping
- You can create tables based on the new classes and properties using the method for creating and executing DDL scrip
- You cannot get automatically the schema changes from the database during runtime. This is something you can only handle manually if it is necessary to be performed. After that, based on what you read from the database you can use the above mentioned capabilities to define your classes and mapping.
I hope this helps and you are able to implement your scenarios using the current functionality. In any case, do not hesitate to contact us for further assistance.
the Telerik team
Currently I am able to determine what New Tables exist in the Database and what tables have extra Columns than what I have defined in the rlinq.
With that information I should be able to create new Classes for the New tables and add new columns to existing class at run time.
Is that correct?
If so can you provide pointers as to where to begin? Would I use the Fluent API? I have tried to follow the documentation but don't really know where to begin?
Thanks for your help.
We do not offer an API for retrieving the database schema, nor an API that is comparing the results of that retrieval with the schema information available in the Domain Model. This is something that is currently supported only during design time. If you need such functionality, you would have to implement it manually.
If you do implement this functionality according to your needs, you can use our Fluent API to define classes and map them to tables. You can achieve that using one of the following approaches:
1) You can use the rlinq file for the tables you already know about. There are two major approaches for presenting the rlinq model into code:
1.1) Using the standard Xml/Attributes mapping - in this case you will have an auto-generated OpenAccessContext only and you will have to add manually a FluentMetadataSource implementation with a PrepareMapping method as shown in the article
1.2) Using the new Fluent Mapping Code Generation available in the Q1 2012 release, which will directly generate the Fluent API code, which you will have to only enhance in order to be able to add your classes at runtime
2) You can directly start with a Code-Only implementation (using Fluent API). In this case you won't be using a visual designer at all - all the classes will be defined in your code (both the existing ones and the dynamically added ones). After that, like in case 1.2, you will just have to enhance the fluent mapping code with some functionality for dynamically adding types, as shown in the artificial types documentation.
Let me know if you need any clarifications or you have other questions.
the Telerik team