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

  • SEARCH
  • Home
  • 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 179163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:21:30+00:00 2026-05-11T14:21:30+00:00

I am serialzing a linq object through WCF. The dbml is setup for unidirectional

  • 0

I am serialzing a linq object through WCF. The dbml is setup for unidirectional serialization.

My objects are pretty simple: Budget has a collection of BudgetLineItems. Each BudgetLineItem has an ItemCateogry.

Budget/BudgetLineItems are serialized fine. ItemCateogry on each BudgetLineItem do not, however. I noticed by default, linq didn’t add a [DataMember] on ItemCategory for each BudgetLineItem. I added it manually, and also removed any possible circular reference on the ItemCategory entity with [IgnoreDataMember]. Not luck, however.

questions:

  1. Can wcf, by default, serialize many-to-one relationships, or am I just missing something? I know the serialized data would be rather redudant with duplicated ItemCategory data for each BudgetLineItem, but that is fine.

  2. Do I need to do a custom DataContractSerializer for this?

** EDIT ** Actually, that did work (adding [DataMember]), I just didn’t update the service reference on the client (duh).

NEW QUESTION: Is there a way to tell the linqtosql designer to maintain those [DataMember] and [IgnoreDataMember] fields on an entity that the designer is generating? otherwise I’ll need to update them everytime I save the dbml.

  • 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. 2026-05-11T14:21:31+00:00Added an answer on May 11, 2026 at 2:21 pm

    Wow you successfully serialized your LINQ 2 SQL objects for WCF?

    When I tried this (very reluctantly, see below as to why) it really fell over, there were relationships in my L2S entity pointing to children, and then the child pointing back to the parent and obviously when enumerating for building the WCF object, it could not traverse the tree infinitely in this fashion and [to the best I remember] it resulted in an overflow exception, so what I am basically saying is beware if you go down this road!

    Following up on Michael’s post, I would suggest transforming your WCF objects to POCO’s (custom model representation). I’m kind glad the above did not work, as I would always prefer to make a custom WCF object which transports a clean subset of data, exactly what the WCF request needs and it then doesn’t include a stack of superfluous data to be sent across the data, and I’m sure your L2S entities have lots of it. The actual reason I tried sending my L2S data directly across the wire was because I had to make an engine which employed certain ‘rules’ these rules were stored in a correlation of about 4 database tables with relationships and it was not viable to upkeep a separate WCF object.

    So in the end what I ended up doing was extending custom code gen classes to include Wcf.cs with [DataContext] and then cloned property for property the L2S classes -> WCF custom classes.

    It worked perfectly in the end and this is the cloning procedure I used with instructions on my blog.

    I am happy with this and don’t feel there is bad practice involved. Hope this helps.

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

Sidebar

Ask A Question

Stats

  • Questions 89k
  • Answers 89k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Making class internal by default makes perfect sense to me:… May 11, 2026 at 5:52 pm
  • Editorial Team
    Editorial Team added an answer To avoid confusion, I won't use the term "object" in… May 11, 2026 at 5:52 pm
  • Editorial Team
    Editorial Team added an answer To answer your question, we first need to differentiate between… May 11, 2026 at 5:52 pm

Related Questions

I am serializing a class using simple-xml ( http://simple.sourceforge.net/ ) but when i try
I have a HashMap that I am serializing and deserializing to an Oracle db,
I have a common code of serializing a class object in my 3-4 methods
I am trying to figure out the best way in an asmx web service

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.