3 Answers, 1 is accepted
In general, OpenAccess generates the domain methods for the stored procedures in the context file of the domain model. So, if you want to call a domain method you need to reference the context assembly from your project and create an instance of the context in it. Moreover, if the called method returns a non-scalar value but a persistent type or complex type you will have to add a reference in your project to the entities assembly as well.
In fact, if you provide us with a more detailed description of your scenario, we might be able to give you a better advise.
If additional questions come up, do not hesitate to get back to us.
Kind regards,
Doroteya
the Telerik team
Indeed, the context generated with the Domain Context wizard does not include the domain methods created in the domain model. This is an additional feature in our backlog and it will be implemented for one of our future releases.
In the meantime, we offer the following workaround:
Creating the Domain Entities assembly
1. Generate a domain model with the Generate Context option selected (named EntitiesModel for example)
2. Open the .rlinq file in Visual Designer
3. Find the stored procedure in the Model Schema Explorer
4. Right-click on it and select Create Domain Method
5. In the Stored Procedure Editor specify a name for the method, a result type and click OK
6. Save the .rlinq file, so that the context is regenerated
Creating the Domain Context assembly
1. Add a Class Library to your project
2. Delete the Program.cs file from it
3. Add references to the Domain Entities assembly, Telerik.OpenAccess.dll and Telerik.OpenAccess.35.Extensions.dll
4. Add a Telerik OpenAccess Domain Context item to the assembly
5. Give it a name (OpenAccessDomainContext, for example), choose a metadata source, select the entities and click Finish
Copying the domain methods
1. Expand the EntitiesModel.rlinq tree in the Domain Entities assembly
2. Open the context file (EntitiesModel.cs)
3. Select the domain methods you want to use
4. Paste them in the OpenAccessDomainContext.cs file before the GetBackendConfiguration() method
Clearing the context in the Domain Entities assembly
1. Open the .rlinq file in Visual Designer
2. Right-click on it and select Show Model Settingsā¦
3. Choose the Code Generation tab
4. Deselect the Generate Context option
5. Click OK
6. Save the .rlinq file so that it clears the content of context and not add code there anymore
Creating the UI
1. Add a console application to your solution
2. Copy the App.Config file from the Domain Entities assembly to it
3. Add references to the Domain Entities assembly, to the Domain Context assembly, to Telerik.OpenAccess.dll and Telerik.OpenAccess.35.Extensions.dll
4. In the .cs file write some code to use the method
5. Enjoy the output
Let us know if that works for you.
All the best,
the Telerik team