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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:08:08+00:00 2026-06-10T21:08:08+00:00

#region Properties public int ID { get; set; } public string Name { get;

  • 0
#region Properties
public int ID
{
    get;
    set;
}
public string Name
{
    get;
    set;
}
public string MetaTitle
{
    get;
    set;
}
public string MetaDescription
{
    get;
    set;
}
public virtual int WebsiteID
{
    get;
    set;    
}
public DateTime TimeStamp
{
    get;
    set;
}
#endregion Properties

#region Methods 
public void Insert()
{
    string sqlString = "INSERT INTO Pages ([name], [value], [meta_title], [meta_description], [website_id]) " +
        "VALUES (@Name, @Image, @Description, @MetaTitle, @MetaDescription, @WebsiteID);";
    SqlConnection sqlConnection =
        new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
    using (SqlCommand sqlCommand = new SqlCommand(sqlString, sqlConnection))
    {
        sqlCommand.Parameters.AddWithValue("@Name", this.Name);
        sqlCommand.Parameters.AddWithValue("@Image", this.Image);
        sqlCommand.Parameters.AddWithValue("@Description", this.Description);
        sqlCommand.Parameters.AddWithValue("@MetaTitle", this.MetaTitle);
        sqlCommand.Parameters.AddWithValue("@MetaDescription", this.MetaDescription);
        sqlCommand.Parameters.AddWithValue("@WebsiteID", this.WebsiteID);
        try
        {
            sqlConnection.Open();
            sqlCommand.ExecuteNonQuery();
            sqlConnection.Close();
            sqlConnection.Dispose();
        }
        catch (SqlException e)
        {
        }
    }
}

Two questions:

I have another class called Section which will derive from the class above called Page. However, Section will not have a WebsiteID but will have a PageID instead. They’re both integers but how do I go about changing the property name is the derived class.

The second thing is, should I override the Insert() method to use another sqlString? If not, what is the best way of implementing such requirements?

Thanks in advance.

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

    I think your inheritance might be a bit off. A “section” is NOT a “page”, or is it?

    Why not have a base class, called Content or something like that, with the properties:

    public int ID { get; set; }
    public string Name { get; set; }
    public string MetaTitle { get; set; }
    public string MetaDescription { get; set; }
    public DateTime TimeStamp { get; set; }
    

    And have Page extend it adding the WebsiteID and Section adding the PageID.

    But I would also recommend separating the entity model from the data access. Using something like Entity Framework or NHibernate to handle persistence for you would save you from having to write that code manually.

    That way you could have a more connected model, where Section actually references a Page entity, and not handle IDs manually. Also Page could contain Sections in the same manner (like a List<Section>), and you’d possibly have a cleaner model.

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

Sidebar

Related Questions

When working on C#, I often do this: #region Properties public int Property1{get;set;} ...(more
class UserClass{ #region Class properties which are binding from DB . . . #endregion
I created this class public class Usuario { #region Atributos private int _intID =
I'm trying to serialize the following object: [XmlRoot(book)] public class Book { #region Properties
I got the following code : public class PluginShape : INotifyPropertyChanged { private string
Here will explain in detail: I have public class Season { #region Public Variables
User Region Points Last_Updated 1 5 0 1-Nov-09 I want this row 2 1
Suppose the following route: {region}/{storehouse}/{controller}/{action} These two parameters region and storehouse altogether identify a
How can I change region for role after initial deployment? I can't find any
I have a coordinate region that I have determined contains the limits of what

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.