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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:44:55+00:00 2026-05-24T16:44:55+00:00

The case is: [ServiceContract] public interface IInfo { [DataMember] int Id{get;set;} } [DataContract] [KnownType(typeof(Legal))]

  • 0

The case is:

[ServiceContract]
public interface IInfo
{
    [DataMember]
    int Id{get;set;}
}

[DataContract]
[KnownType(typeof(Legal))]
public class Info
{
    [DataMember]
    public int Id { get; set; }
}

[DataContract]
public class Legal : Info
{
    [DataMember]
    public string ManagerName { get; set; }
}

[ServiceContract]
[ServiceKnownType(typeof(Legal))]
public interface IMyService
{
    [OperationContract]
    int DoWork(Info dto);
}

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class MyService : IMyService
{

    public int DoWork(Info dto)
    {
        string name;
        if (dto is Legal)
            name = (dto as Legal).ManagerName;
        return dto.Id;
    }
}

Is it possible to know the dto as Legal type and have access to the child properties?

I want to store the dto and I don’t want to have many services for each child of info.

Passing Generics to service doesn’t work, wsdl error,
Interface such as IInfo as input parameter doesn’t work, casting error,
Base class like Info doesn’t work, child props are not accessible,
stack overflow doesn’t work, this is my 2nd time i post this prob but no answer!

  • 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-24T16:44:56+00:00Added an answer on May 24, 2026 at 4:44 pm

    I’m passing a json as dto to MyService.
    If i add “__type”:”Legal:#Dto”, MyService recognize the dto as Legal.
    then (dto as Legal).ManagerName has value

    This solution is working, actually passing __type is not handy way. I’ll appreciate your better suggestions.

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

Sidebar

Related Questions

Case: public class customer { public string Adress { get; set; } } Xaml:
WCF Service INTERFACE : [ServiceContract] public interface ITest { [OperationContract] int TestCall(GenericType<MyType> x); [OperationContract]
please check the below example namespace GServices { [ServiceKnownType(typeof(SearchType))] [ServiceContract(SessionMode = SessionMode.Allowed)] public interface
case class Test(kind: Int) { val ifX = if (isX) is X else not
Case 1 I have 2 synchronized methods as shown below: class A { public
My WCF Service in C# looks like this. [ServiceContract] public class MySecretService { [OperationContract]
case class MyInt(val i : Int) { private def factorial(a : Int) : Int
Case One Say you have a little class: class Point3D { private: float x,y,z;
Case i'm trying to write a GWTTestCase for a certain class, used as a
//case 1:post to main thread's handler mHandler.post(new Runnable(){ public void run(){ dosomething(); //update UI

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.