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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:23:07+00:00 2026-06-09T09:23:07+00:00

I am using entity framework to generate a ‘CClass’ entity as below: public partial

  • 0

I am using entity framework to generate a ‘CClass’ entity as below:

public partial class CClass: EntityObject
{
    #region Factory Method

    #region Primitive Properties
}

My rest of the partial class implementation is

public partial class CClass : IDemoralize
{
    public Value xValue { get; set; }

    public void IDemoralize.Demoralize()
    {
        // implementation

    }
    public void IDemoralize.Demoralize(Func<IDemoralize, bool> CustomDemoralization)
    {
        bool success = CustomDemoralization(this);

        if (!success)
            throw new ApplicationException();
    }

    public void IDemoralize.WriteModel()
    {
        // implementation
    }

    public void IDemoralize.WriteModel(Func<IDemoralize, bool> Write)
    {
        bool success = Write(this);
        if (!success)
            throw new ApplicationException();
    }
}

Now since two methods listed below here does have common implementation across the whole design I want to move them to a base class called DemoralizeBase, so if code needs change then the consistency becomes manageable.

// in DemoralizeBase 
public void Demoralize(Func<IDemoralize, bool> CustomDemoralization)
{
    //implementation
}

public void WriteModel(Func<IDemoralize, bool> Write)
{
    // implementation
}

Is there a way to do this or I should go with the existing design?

  • 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-06-09T09:23:09+00:00Added an answer on June 9, 2026 at 9:23 am

    You could write those as extension methods:

    public static class Demoralize {
        public static void Demoralize(this IDemoralize obj,
             Func<IDemoralize, bool> CustomDemoralization) {...}
        public static void WriteModel(this IDemoralize obj,
             Func<IDemoralize, bool> Write) {...}
    }
    

    This will then work as though it were an instance method, i.e.

    var foo = new CClass();
    foo.Demoralize(...);
    

    One thing to watch: when calling extension methods on the current instance, the this. (which is usually optional) is required, i.e.

    Demoralize(...); // does not work
    this.Demoralize(...); // works
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When using LINQ-to-SQL or Entity Framework , I can easily generate a class for
(USING ENTITY FRAMEWORK 4.3 CODE FIRST) The code is below. I want to actually
I'm using Entity framework 4.3.1 installed by nuget in my .Net 4.0 class library
I have a simple table called News . I'm using Entity Framework to generate
I am using Entity Framework POCO to generate some self-tracked data objects, and I
I am trying to generate sql query using .ToTraceString() in entity framework 3,5; but
I've created a database model with model-first method using Entity Framework 4.0. I then
I've been playing with Entity Framework 4, using the model driven approach to generate
I am using entity framework 4.1, an edmx mapping file is used to generate
(using Entity Framework) when i write : IEnumerable<string> q = customers /*EF entity*/ .Select

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.