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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:01:10+00:00 2026-05-25T21:01:10+00:00

I am using automapper to map a master class to various child classes. Example:

  • 0

I am using automapper to map a master class to various child classes.

Example: I have a class called VitalStatistics (master class). This class holds all fields for a record.

The company business rules indicate that only certain fields are needed based on the State location.
So, California may not all 20 fields found in the master class and may need only 10 fields instead of the 20. So I use automapper to map the VitalStatis class data to the CAVitalStats class which has only 10 fields. The TXVitalStats class may only have 3 fields. etc..

My web services need to return a type that these classes have in common. E.g. IVitalStatistics interface.

It seems as though the WCF service does not like an interface declared as the return type.
So, how can I get the service to return CAVitalStats or TXVitalStats? Normally if these both were of the same interface type then this would work because they all would be of type IVitalStatistics but the serialization messaging rules appear to have a problem with returning interface types.

I hope this made sense. Thanks

  • 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-25T21:01:10+00:00Added an answer on May 25, 2026 at 9:01 pm

    If you have CAVitalStats and TXVitalStats both inheriting from the same base class, for instance ‘VitalStatsBase’, then your service method could return VitalStatsBase.

    To make this work with your 2 subclasses you’ll need to use the KnownTypeAttribute in your service.

    Below is a link describing the KnownTypeAttribute.

    http://msdn.microsoft.com/en-us/library/ms730167.aspx

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

Sidebar

Related Questions

I am using automapper to map my models to viewmodel classes to pass to
Does anyone have a technique to automap (using Automapper) references to child entities. So
In a project using NHibernate, I have this class : public class AdminVAT :
In my ASP.NET MVC2 application, I have a ViewModel class called UserCreateViewModel. In this
I'm using AutoMapper to map domain entities to view models in an Asp.Net MVC
I'm using AutoMapper to map between a Linq Domain object and a ViewModel to
I am using automapper (successfully up to a point) to perform a polymorphic map
I have recently started using automapper and it has work fine for me so
I have a class which I would like to map as a component onto
I have been using automapper pretty successfully lately but i have come across a

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.