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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:12:41+00:00 2026-05-25T03:12:41+00:00

Due to a recent issue i had some days ago (you can check this

  • 0

Due to a recent issue i had some days ago (you can check this post here), i needed to create a way that some of my linq to sql tables could be referenced dynamically. I’ve managed to do that through an abstract LogTable class, which contains all my LogTable properties as defined on my DataTable. I was able to do this abstract way because my LogTables have the same structure, thus the same properties.

Heres the reducted code:

Abstract base class

public abstract class LogTableStructure
{
        public int ID { get; set; }

        public datetime? LastAccess { get; set; }

        public string Username { get; set; }
}

My (reducted) dynamic method to update a LogTable:

public void UpdateLog<T>(T currentLOG) where T : LogTableStructure
    {

        LogTableStructure logStructure = null;

        //LogTableEnum is defined on this class constructor
        switch (LogTableEnum)
        {
            case LogTableEnum.Log2009:
                logStructure = this.factory.LogDB.LOG_2009s
                    .SingleOrDefault(q => q.ID == currentLOG.ID);
                break;
            case LogTableEnum.Log2010:
                logStructure = this.factory.LogDB.LOG_2010s
                    .SingleOrDefault(q => q.ID == currentLOG.ID);
                break;
            case LogTableEnum.Log2011:
                logStructure = this.factory.LogDB.LOG_2011s
                    .SingleOrDefault(q => q.ID == currentLOG.ID);
                break;
   }
}

PROBLEM

for some reason the currentLOG param throws a runtime null reference exception, even though it has all LogTable properties filled. I’ve notice by using vs2010 debbuger that while the currentLOG properties are filled, the base class (LogTableStructure) properties are all empty, as if the base object is null.

Am i forgeting something about member hide inheritance or something alike? I’ve even added the new modifier to all my LogTable properties on my .dbml, but even that didn’t solve the problem

  • 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-25T03:12:42+00:00Added an answer on May 25, 2026 at 3:12 am

    Just make the object into which you’re injecting an actual instance:

    // This object is going to have to be a class that inherits from your abstract class
    // It can't be a null object of the type of your abstract class.
    var logStructure = new InstanceOfLogTableStructure();
    logStructure.InjectFrom(currentLOG);
    

    That should do it.

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

Sidebar

Related Questions

I can't figure out why I'm getting this error. Please help. Traceback (most recent
Sorry folks...first post here. Just getting the hang of this site. Thanks for the
Due to a sad situation I receive HTML like this: <p>Perform the following commands:
Due to some css limitations between IE and the rest of the world I
Due to the lack of documentation for this on MSDN, I am forced to
I recently asked a question (and had it answered) here: jQuery Load JSON I
Due to recent events, i am trying to figure out how much debugging logs
A recent mention of PostSharp reminded me of this: Last year where I worked,
This problem is partly due to my lack of completely understanding scoping in python,
While answering a particular question here in SO I stumbled upon a peculiar issue

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.