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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:03:14+00:00 2026-05-20T15:03:14+00:00

I have an entity model which has some tables added from my DB. I

  • 0

I have an entity model which has some tables added from my DB. I want to include a custom class which will act as a data model and will return customized data. Here is what I am trying to do:

// My custom data model
public class DataModel
{
    var dbContext = new ODataDemoEntities();

    Employees = from e in dbContext.Employee
                select new EmployeeModel
                {
                    ID = e.EmployeeID,
                    FirstName = e.FirstName,
                    LastName = e.LastName
                };

    public IQueryable<EmployeeModel> Employees { get; private set; }
}

// My custom class
[DataServiceKey("ID")]
public class EmployeeModel
{
    /// <summary>ID of the employee.</summary>
    public int ID { get; set; }

    /// <summary>First name of the employee.</summary>
    public string FirstName { get; set; }

    /// <summary>Last name of the employee.</summary>
    public string LastName { get; set; }
}

// My WCF Data Service Code
public class EmployeeDataService : DataService<DataModel>
{
    // This method is called only once to initialize service-wide policies.
    public static void InitializeService(DataServiceConfiguration config)
    {
        config.SetEntitySetAccessRule("Employees", EntitySetRights.AllRead);
        config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
    }
}

However I want to include this Employees class in my existing entity data model class, so that rather than creating separate service with different data model, I extend my existing data model to include my custom class (EmployeesModel) too.

  • 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-20T15:03:14+00:00Added an answer on May 20, 2026 at 3:03 pm

    Why would you want to expose a customized view over an existing entity? The client can do this anyways and customize them in the way they want using projections. The query on the client side would exactly look like the one who wrote above to initialize the Employees property.

    Currently, there is no way to do this. We are looking into ways to make sure happen in our next release. No promises though, but there is one of the things we have been asked a number of times and its pretty high in our proirity list.

    Use this voting site to vote for this feature: http://blogs.msdn.com/b/astoriateam/archive/2010/09/10/what-do-you-want-to-see-added-changed-in-wcf-data-services.aspx

    Thanks
    Pratik

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

Sidebar

Related Questions

I have entity class which is used to model a weather station, and it
I have an entity class that has a property with an underlying db column
When I have a CoreData entity named, say, 'Book', which has a one-to-one relationship
I have an entity which has a collection as one of its attributes. That
I have a View Model that has some serious nesting. I need to populate
In my Core Data managed object model, I have an entity Foo with a
We have a simple domain model: Contact, TelephoneNumber and ContactRepository. Contact is entity, it
We're using interfaces to represent entity classes in our domain model. We have concrete
I have an entity that maps to an external oracle table which is one
Using NHibernate.Mapping.Attributes, I have a entity class with something like: [Class] public class EntityA

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.