Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6197927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:54:27+00:00 2026-05-24T03:54:27+00:00

Is it possible to use objects of Entity classes as Data Contract on WCF

  • 0

Is it possible to use objects of Entity classes as Data Contract on WCF service ? So I can send them on the client side. is this good design approach ?

I want to my entity classes to be used as DTOs too, so I can send the data retrieved from database to the client.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T03:54:28+00:00Added an answer on May 24, 2026 at 3:54 am

    Yes it is. If you use EntityObject based entities both default code generator and T4 template should mark them with DataContract and DataMember attributes. If you use POCOs you will have to either modify template to generate these attributes for you or create POCOs manually.

    The reason why you need to use those attributes is problem with circular reference. By default EF creates navigation properties on both sides of relation. During serialization, framework needs some hint to know about that circular reference otherwise it will go to infinite loop. To avoid that the entity must be marked with [DataContract(IsReference=true)] and once you use DataContract attribute you must use DataMember to mark each serialized property.

    It is also important to turn off lazy loading because otherwise serialization will trigger lazy loading on every navigation property and it will do this recursively on all lazily loaded entities. So instead of single object you can return from your service all its relations, all their relations, etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It is possible to use AND while querying for Objects in Entity like Post.find(byTitleLikeAndAuthor,
Our project makes use of gilead to pass model objects to the client side
Is it possible to use the .NET configuration objects to get at .config files
I'm getting data where the database is hidden behind a WCF service. Is it
Okay, I need some help here. This is the same old "can't use an
Possible Duplicate: Why not use an IoC container to resolve dependencies for entities/business objects?
I am using a Data Entity from the db, and a Domain Service. I
Is it possible to use an ActiveX/COM object from ColdFusion? If so, where's the
Is it possible to use PHP's SimpleXML functions to create an XML object from
Is it possible to use the __unused attribute macro on Objective-C object method parameters?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.