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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:46:02+00:00 2026-05-28T14:46:02+00:00

I have multiple interfaces that my objects can implement. I am wondering if there

  • 0

I have multiple interfaces that my objects can implement. I am wondering if there is a way to “cascade” one extension method into another while using the same method name. I may be looking at this all wrong, but here is an example:

public interface IBaseDto
{
     int Id {get;set;}
     string CreatedByFullName {get;set;}
}

public interface IDocumentDto
{
     List<ContactDto> Subscriptions {get;set;}
}

public class ContactDto: IBaseDto
{
     public int Id {get;set;}
     public string CreatedByFullName {get;set;}
     public string FirstName {get; set}
     public string LastName {get;set;}
}

public class MeetingDto: IDocumentDto
{
     public int Id {get;set;}
     public string CreatedByFullName {get;set;}
     public List<ContactDto> Subscriptions {get;set;}
}

So, let’s say I want to convert the DTOs into entities using an extension method. An example would be MeetingDto.ToEntity();

I am trying to think if I can write part of the extension method for an IBaseDto, another for the IDocumentDto and then for each concrete implementations for just their own properties. When I call MeetingDto.ToEntity() it would first hit the meeting extension method and call the IDocumentDto version, fill in what it needed, and then the IDocumentDto would call the IBaseDto. I hope this makes sense.

UPDATE:

I came up with this and it works pretty well:

public static TBaseDto ToEntity<TBridgeDto>(this TBaseDto dto) where TBaseDto: IBaseDto
        {
...            
return dto;
        }


        public static TDocumentDto ToEntity<TDocumentDto>(this TDocumentDto dto, IDocumentDto currentDto) where TDocumentDto : IDocumentDto
        {
...            
return dto.ToEntity();
        }

        public static MeetingDto ToEntity(this RfiDto dto)
        {
...            
return dto.ToEntity(dto)

        }
  • 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-28T14:46:02+00:00Added an answer on May 28, 2026 at 2:46 pm

    Like this?

    public static class Helper
    {
        public static void ToEntity(this MeetingDto source)
        {
            Console.WriteLine ("MeetingDto.ToEntity");
            //Do Stuff
            (source as IDocumentDto).ToEntity();
        }
    
        public static void ToEntity(this ContactDto source)
        {
            Console.WriteLine ("ContactDto.ToEntity");
            //Do Stuff
            (source as IBaseDto).ToEntity();
        }
    
        public static void ToEntity(this IDocumentDto source)
        {
            Console.WriteLine ("IDocumentDto.ToEntity");
            //Do Stuff
            foreach (var element in source.Subscriptions)
            {
                element.ToEntity();
            }
        }
    
        public static void ToEntity(this IBaseDto source)
        {
            Console.WriteLine ("IBaseDto.ToEntity");
            //Do Stuff        
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class that implements multiple interfaces. I would like to register these
If we have a class that inherits from multiple interfaces, and the interfaces have
I have an interesting challenge that I'm wondering if anyone here can give me
I have webservice that can return data in multiple formats. For example json and
We have an idl file with multiple interfaces defined, two of which have someting
I have multiple selects: <select id=one> <option value=1>one</option> <option value=2>two</option> <option value=3>three</option> </select> <select
I have multiple classes that all derive from a base class, now some of
I have an issue that I feel many programmers can relate to... I have
I have a worker class that does stuff with a collection of objects. I
I have to implement a multiple producers / multiple consumers example application for 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.