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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:26:49+00:00 2026-06-08T20:26:49+00:00

I am trying to write my first RESTful API in C# using ASP.NET Web

  • 0

I am trying to write my first RESTful API in C# using ASP.NET Web API and Entity Framework.

My issue is that the list that returns from my EF query is polluted with entity key information that is useless (I found out that because my columns are nullable if thinks they all must be keys).

Here is a part of the XML response I receive from my API call

<syemploy z:Id="i1"><EntityKey z:Id="i2">
<d2p1:EntityContainerName>AbraHRMS_LiveEntities</d2p1:EntityContainerName>
<d2p1:EntityKeyValues>
    <d2p1:EntityKeyMember>
       <d2p1:Key>id_col</d2p1:Key>
       <d2p1:Value i:type="d5p1:int">15</d2p1:Value>
    </d2p1:EntityKeyMember>
    <d2p1:EntityKeyMember>
       <d2p1:Key>e_address1</d2p1:Key>
       <d2p1:Value i:type="d5p1:string">153 Townsend Street, Suite 9057</d2p1:Value>
    </d2p1:EntityKeyMember>
...

How can I remove the entity key values from the response?
My c# code looks like this

 AbraHRMS_LiveEntities _db = new AbraHRMS_LiveEntities();

 # GET api/employee
 public List<MvcApplication1.DAL.syemploy> Get()
 {
    return _db.syemploys.ToList();
 }

Again, this is my first API in C#, so if anything is funky looking please feel free to point it out.

  • 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-06-08T20:26:50+00:00Added an answer on June 8, 2026 at 8:26 pm

    By default you’ll have all public properties of your entities in XML. To avoid having them in response, try to create “new” class which doesn’t contain undesirable fields and then convert your result to the list of “new” type objects. You can use .Select() or .Cast() on _db.syemployes for that. Keep in mind that syemploy class should be convertible to “new” class in case you want to call Cast<> method. You can read here about type conversion in C#. If you use .Select() then construct objects of new type inside of select’s lambda expression.

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

Sidebar

Related Questions

I am trying to write my first ASP.NET website and I really want to
I'm a Silverlight/ASP.NET developer trying to write my first Windows Forms application to run
I'm trying to write my first iPhone app, and I'm using a date picker
I am trying to write a regex that matches the following: first an optional
I'm trying to write my first semi advanced bash script that will take input
I'm trying to write my first Perl program. If you think that Perl is
I'm trying to write my first query that uses a database join. I've gone
Hi I'm trying to write my first Wordpress plugin. I'm using classes to make
I am trying to write my first real python function that does something real.
I'm trying to write my first xsd schema, and have run into an issue.

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.