how to use generated classes with WCF?

2 posts, 0 answers
  1. MrX
    MrX avatar
    1 posts
    Member since:
    Oct 2013

    Posted 25 Oct 2013 Link to this post

    Hi guys!

    I am currently converting a system with several WPF apps, one of them a server app, from using MS SQL Server Express to using PostgreSQL. I have been evaluating OpenAccess for the last couple of days to see if it can be used. The apps use WCF to send some of the persisted classes/entities between them via intranet. All apps in the system are basically just plain VS2010 WPF apps.

    So far it looks as if I can use OpenAccess forward mapping to solve the Db persistance parts. Great!

    But what to do about the WCF parts? How can I get all persisted classes and properties that are automatically generated by OpenAccess decorated with DataContract and DataMember so they can be used by the WCF proxies we have?

    I have seen in the Forum that this has been asked once or twice before. But I have seen no real answer. Just a two liner with a broken link to some documentation page and something that looked suspiciously like "here you are, now go figure it out for your self". Not very helpful! Telerik support should be able to do better than that, at least I hope so.
    I would really appreciate a detailed answer and a solution to this problem, and there are probably others who are interested too. 

  2. Kristian Nikolov
    Kristian Nikolov avatar
    206 posts

    Posted 29 Oct 2013 Link to this post


    Our code generation templates can be customized so that DataContract and DataMember attributes will be added automatically to your persistent classes and their properties respectively.

    I have prepared a set of customized templates which will generate the aforementioned attributes, please find them attached to my answer. To apply the templates follow these steps:
    1. Create a new folder in the project containing your Domain Model. This folder will contain the customized templates.
    2. Copy the customized templates ( and the entire Includes_ver.2 folder) in the newly created folder.
    3. Select in the Solution Explorer, open its properties window and clear the value for the Custom Tool property.
    4. Double click on the .rlinq file of your model to open the Visual Designer, right-click its surface and select the Show Model Settings... option from the menu. This will open the Model Settings dialog.
    5. Select the Code Generation tab.
    6. Chose the Custom Defined option.
    7. Click the Select Existing... button and select the from the custom templates folder in your project.
    8. In your model project add a reference to the System.Runtime.Serialization assembly.
    9. Save your model and the classes and their properties will be regenerated with their respective properties.

    Please note that in order to use instances of the persistent classes as DTOs you will need to detach them from the context before passing them to the client application or attach them to the context after they have been passed to the service by the client application. To do that you can use our Attach/Detach API.

    I hope this helps.

    Kristian Nikolov
    OpenAccess ORM Q3 2013 simplifies your model operations even further providing you with greater flexibility. Check out the list of new features shipped with our latest release!
  3. DevCraft banner
Back to Top