After you define the service operations in Xomega, you can quickly and easily create implementation classes for such services by first using a generator to create an initial implementation of the service class and then leveraging the power of Xomega Framework, Entity Framework and the LINQ technology to implement the business logic of your service. This helps you to stay focused on the functionality of your system rather than on the plumbing code that is necessary to make it all work.
Here's a sequence of steps you can take to create the implementation classes for your services.
- Define your operations including the input and output structures in your model. You can also leverage the generator of the standard CRUD operations and then update them for your specific needs, or you can define the operations from scratch.
- Configure the namespaces for the generated service classes.
- Generate the WCF Service Contracts from the operations.
- Open the properties tab of the Service Implementation generator in the Business Layer generator group.
- Set the Output Path parameter to where you want the generated classes to go. Use the {File} placeholder to indicate the location of individual services. You can also use the {Module/} placeholder to place services in different folders based on the modules of the corresponding objects, for example ../MyProject.Entities/{Module/}_{File}.cs. We recommend outputting the generated files into a dedicated directory or using a certain naming convention, so that it won't overwrite the manually update files.
- If you want the generator to automatically add the generated files to one of your projects, then you need to specify the path to the project file in the Add To Project parameter.
- Run the generator and add the generated files to your project as necessary.
- Review the generated classes. If the model needs to be updated, then make the necessary changes and regenerate using the steps above. Otherwise rename/move the generated file, so that it doesn't get accidentally overwritten by a subsequent rerun of the generator.
- Update the generated implementation to use/populate all the input/output parameters that were not properly handled by the generated code. Generally, the generator will create TODO comments for each such parameter for you to implement.
- Implement the business logic of the service operations using the Xomega Framework, Entity Framework and LINQ. You can read this article on how to build WCF services with Xomega Framework.
If you already have a manually coded service implementation class and need to update an existing operation or define a new operation in the model, then you can still use the generator to create a service implementation class using the steps above, but instead of copying and/or renaming the generated file you can copy just the part of the generated code that is related to your update and paste it into your existing implementation class as appropriate.