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 672951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:32:29+00:00 2026-05-14T00:32:29+00:00

Say you have a one to one relationship in your entity model. The code

  • 0

Say you have a one to one relationship in your entity model. The code generator will decorate it with the following attributes:

[global::System.Xml.Serialization.XmlIgnoreAttribute()]
[global::System.Xml.Serialization.SoapIgnoreAttribute()]
public RelatedObject Relationship { get {...} set {...} }

I want to serialize my parent object together with all its properties for which data has been loaded through an XML web service. Obviously, these related properties do not get serialized because of these attributes.

So for my purposes I just want to remove these “don’t serialize me” attributes. I can do a find and replace in the designer code, but any modifications I make in the designer will put these attributes back in.

In my query I’m .Include()ing and explicitly loading only the child objects that I require for serialization. So I will make sure there are no circularities in my query. Some of the child properties are not required, so I won’t Include() them, so they won’t be serialized.

Else how do I achieve what I want to do? Make a separate call from my application for each child object? Say I’m returning hundreds of parent objects; I’d have to make hundreds of separate calls to get each child too.

How do I permanently get rid of these attributes?

VS 2008 / EF 3.5.

  • 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-14T00:32:29+00:00Added an answer on May 14, 2026 at 12:32 am

    Here is a little known fact… Entity Framework + Web Services = :'(

    There are three(3) approaches that can be taken to solve your problem (namely the XML graph serialization problem… or the lack of it).

    I will list each approach in order of least development time and complexity of implementation required [“Bang-For-Buck”] vs. scalability, maintainability and performance [“Future Proofing”].

    1. Create POCO classes for each Entity for projection when sending over the wire. This is the easiest (and monotonous) approach but will solve your problem. I have included a sample at the end.

    2. Use WCF to relay your data. Entity Framework and WCF are like ‘brothers from a different mother’. They were designed to work together but share their differences. You will notice that all EF generated Entity Objects are inherently [DataConctract] with all fields being [DataMember]. This makes use of the WCF DataContract Serializer with handles graphs very efficiently and maintains object reference even after deserialization. WCF DataContract Serializer is also proven to be 10% quicker than your default XML Serializer.

    3. Use EF 4.0 Self Tracking Entities (STE). This is still very new but it is workable. In Visual Studio 2010 you are given an option to generate Self Tracking Entities which are designed for N-Tier and SOA. The best thing about STE is the usage of T4 Transformed Text templates to generate the code. The classes generated by T4 is clean and very malleable, giving you plenty of room to insert your logic and validation. Here is a link to STE tutorial to get your started.

    Best of luck and I hope you find the best approach for you.

    POCO example.

    public class CustomerPOCO
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public List<SubLocationPOCO> SubLocations { get; set; }
        // ...
    
        #region Ctors
    
        public CustomerPOCO() { }
    
        public CustomerPOCO(Customer customer)
        {
            // Inits
            if (customer.SubLocations != null)
                SubLocations = customer.SubLocations.Select(sl => new SubLocationPOCO(sl)).ToList();
        }
    
        #endregion
    
    }
    
    
    public class SubLocationPOCO
    {
        public int ID { get; set; }
        public string Name { get; set; }
    
        #region Ctors
    
        public SubLocationPOCO() { }
    
        public SubLocationPOCO(SubLocation subLocation)
        {
            // Inits
        }
    
        #endregion
    
    }
    

    And your [WebMethod] is something like this.

    [WebMethod]
    public CustomerPOCO GetCustomerByID(int customerID)
    {
        using (var context = new CustomerContext())
        {
            var customer = (from customer in context.Customers.Include("SubLocations")
                            where customer.ID == customerID
                            select new CustomerPOCO(customer)).FirstOrDefault();
    
            return customer;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Update your style to reflect this: <div id="container"> <div class="lfbtn"></div>… May 14, 2026 at 1:48 am
  • Editorial Team
    Editorial Team added an answer you should create a regex expression. to check if the… May 14, 2026 at 1:48 am
  • Editorial Team
    Editorial Team added an answer Prepared statements created by mysqli_prepare() are server-side prepared statements. When… May 14, 2026 at 1:48 am

Related Questions

Say you have a ServiceCall database table that records down all the service calls
One thing I see in some DDD enterprise apps that I work on, is
Let's say you have a table for branches in your organization. Some of them
Let's say I have two tables employee and salary with a 1:N relationship (one
I have a scenario which is not easy to explain, but I am sure

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.