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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:06:18+00:00 2026-05-11T21:06:18+00:00

I have a class reflecting my dbml file which extends DataContext, but for some

  • 0

I have a class reflecting my dbml file which extends DataContext, but for some strange reason it’s telling me

System.Data.Linq.DataContext’ does not contain a constructor that takes ‘0’ arguments”

I’ve followed various tutorials on this and haven’t encountered this problem, and VS doesn’t seem to able to fix it.

Here’s my implementation

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Reflection;
using System.Text;
using IntranetMvcAreas.Areas.Accounts.Models;

namespace IntranetMvcAreas
{
  partial class ContractsControlDataContext : DataContext
  {
    [FunctionAttribute(Name="dbo.procCC_Contract_Select")]
    [ResultType(typeof(Contract))]
    [ResultType(typeof(ContractCostCentre))]
    [ResultType(typeof(tblCC_Contract_Data_Terminal))]
    [ResultType(typeof(tblCC_CDT_Data_Service))]
    [ResultType(typeof(tblCC_Data_Service))]
    public IMultipleResults procCC_Contract_Select(
        [Parameter(Name = "ContractID", DbType = "Int")] System.Nullable<int> ContractID,
        [Parameter(Name = "ResponsibilityKey", DbType = "Int")] System.Nullable<int> ResponsibilityKey,
        [Parameter(Name = "ExpenseType", DbType = "Char")] System.Nullable<char> ExpenseType,
        [Parameter(Name = "SupplierID", DbType = "Int")] System.Nullable<int> SupplierID)
    {

      IExecuteResult result = this.ExecuteMethodCall(this, (MethodInfo)(MethodInfo.GetCurrentMethod()), ContractID, ResponsibilityKey, ExpenseType, SupplierID);
      return (IMultipleResults)result.ReturnValue;
    }
  }
}

And it’s ContractsControlDataContext that’s pointed at as the problem

(btw, this has no relation to a very recent post I made, it’s just I’m working on the same thing)

EDIT

It’s probably worth clarifying this, so please read very carefully.

If you do not extend DataContext in the partial class, then ExecuteMethodCall isn’t accessible.

‘Intranet.ContractsControlDataContext’ does not contain a definition for ‘ExecuteMethodCall’ and no extension method ‘ExecuteMethodCall’ accepting a first argument of type ‘Intranet.ContractsControlDataContext’ could be found (are you missing a using directive or an assembly reference?)

Maybe I’m missing something incredibly stupid?

SOLVED

I think perhaps Visual Studio struggled here, but I’ve relied entirely on auto-generated code. When right clicking on the database modeling language design view and hitting “View Code” it automagically creates a partial class for you within a specific namespace, however, this namespace was wrong. If someone could clarify this for me I would be most appreciative.

The .designer.cs file sits in namespace Intranet.Areas.Accounts.Models, however the .cs file (partial class generated for the .designer.cs file by Visual Studio) was in namespace Intranet. Easy to spot for someone more experienced in this area than me.

The real problem now is, who’s answer do I mark as correct? Because many of you contributed to finding this issue.

  • 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-11T21:06:18+00:00Added an answer on May 11, 2026 at 9:06 pm

    The object DataContext for linq does not have an empty constructor. Since it does not have an empty constructor you must pass one of the items it is excepting to the base.

    From the MetaData for the DataContext.

    // Summary:
    //     Initializes a new instance of the System.Data.Linq.DataContext class by referencing
    //     the connection used by the .NET Framework.
    //
    // Parameters:
    //   connection:
    //     The connection used by the .NET Framework.
    public DataContext(IDbConnection connection);
    //
    // Summary:
    //     Initializes a new instance of the System.Data.Linq.DataContext class by referencing
    //     a file source.
    //
    // Parameters:
    //   fileOrServerOrConnection:
    //     This argument can be any one of the following: The name of a file where a
    //     SQL Server Express database resides.  The name of a server where a database
    //     is present. In this case the provider uses the default database for a user.
    //      A complete connection string. LINQ to SQL just passes the string to the
    //     provider without modification.
    public DataContext(string fileOrServerOrConnection);
    //
    // Summary:
    //     Initializes a new instance of the System.Data.Linq.DataContext class by referencing
    //     a connection and a mapping source.
    //
    // Parameters:
    //   connection:
    //     The connection used by the .NET Framework.
    //
    //   mapping:
    //     The System.Data.Linq.Mapping.MappingSource.
    public DataContext(IDbConnection connection, MappingSource mapping);
    //
    // Summary:
    //     Initializes a new instance of the System.Data.Linq.DataContext class by referencing
    //     a file source and a mapping source.
    //
    // Parameters:
    //   fileOrServerOrConnection:
    //     This argument can be any one of the following: The name of a file where a
    //     SQL Server Express database resides.  The name of a server where a database
    //     is present. In this case the provider uses the default database for a user.
    //      A complete connection string. LINQ to SQL just passes the string to the
    //     provider without modification.
    //
    //   mapping:
    //     The System.Data.Linq.Mapping.MappingSource.
    public DataContext(string fileOrServerOrConnection, MappingSource mapping);
    

    Something as simple as this would work. Any class that inherits from the DataConext must pass to the base constructor at least one of the types it is excepting.

    public class SomeClass : System.Data.Linq.DataContext
    {
        public SomeClass(string connectionString)
            :base(connectionString)
        {
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 128k
  • Answers 128k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Despite some helpful advice, I never figured this one out,… May 12, 2026 at 5:43 am
  • Editorial Team
    Editorial Team added an answer Use this command: egrep -lRZ "\.jpg|\.png|\.gif" . \ | xargs… May 12, 2026 at 5:43 am
  • Editorial Team
    Editorial Team added an answer You can add an invisible span to the html: <span… May 12, 2026 at 5:43 am

Related Questions

I have a class that I have serialized to disk on local users machines.
We have all heard of premature optimization , but what do you think about
Edit--@Uri correctly pointed out that this was an abuse of annotations; trying to actually
Here's my problem: I have 2 projects - one 'common' projects with acts like

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.