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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:34:01+00:00 2026-05-22T16:34:01+00:00

I have a EnityName called Client and I need it’s collection name Clients, it

  • 0

I have a EnityName called Client and I need it’s collection name Clients, it has to be generic so that I can get the EntitySetName from EntityName for any entity. It’s exposed in the svc file but doesn’t seem to be in the service proxy class. If I can do this then I can have a generic method like.

public void Add<T>(IEnumerable<T> entitySet)
{
    var myService = GetServiceContext();

    foreach (var entity in entitySet)
    {
        myService.AddObject(entity.GetType().Name -- NEEDS TO BE ENTITY SET NAME, entity);
    }

    myService.SaveChanges(SaveChangesOptions.Batch);

}
  • 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-22T16:34:02+00:00Added an answer on May 22, 2026 at 4:34 pm

    Here’s how I implemented it:

        private static string ResolveEntitySet(Type type)
        {
            var entitySetAttribute =
                (EntitySetAttribute) type.GetCustomAttributes(typeof (EntitySetAttribute), true).FirstOrDefault();
    
            if (entitySetAttribute != null)
            {
                return entitySetAttribute.EntitySet;
            }
    
            return null;
        }
    

    An a quick example of calling it (similar to yours, but with a single add):

        public void Add<T>(T entity)
        {
            _entities.AddObject(ResolveEntitySet(entity.GetType()), entity);
        }
    

    Here a peak at how my “Account” entity looks in my proxy class (auto generated in .NET 4 – I didn’t have to add this, but it looks like older versions might???)

    [System.Data.Services.Common.EntitySetAttribute("Accounts")]
    [System.Data.Services.Common.DataServiceKeyAttribute("Id")]
    public partial class Account : System.ComponentModel.INotifyPropertyChanged
    {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this xml in string format. I want to get the attribute called
I have a query that I need to execute against CRM. It is the
I currently have a legacy system that uses SPs exclusively for access to the
I want to write generic method that checks if a given entity is in
I have a java class that is accessed by a lot of threads at
I have a setup where I get some information, in an ajax call, then
I have the need to create a complex predicate for an abstract base object.
I have these two classes public class BuyEstimateResult { public string SubTitle { get;
this my problem i have a class X that inherits UITableViewController class and a
In my app, I have a UITableView that is populated by Core Data, currently

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.