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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:10:49+00:00 2026-06-10T13:10:49+00:00

I am using Visual Studio 2010, ASP.NET MVC 3, with a SQL 2008 R2

  • 0

I am using Visual Studio 2010, ASP.NET MVC 3, with a SQL 2008 R2 Database.

This, I believe is a simple task but I don’t exactly know how to word it. This is the current code I have.

 public static IEnumerable GetAPCBundledCodesData(string CPTCode)
    {

        var result = (from item in new VADataContext().CPT2MODs
                      where item.CPT == CPTCode
                      select new { item.MOD }).ToList();
        return result;
    }

This pulls a list of items in the CPTSMODs table and returns it. What I would like to do is take that result and get another list with matches to every item with the same value in another table called Modifiers with the same field MOD. I’m not sure how to do this part.

I hope I’ve explained this well enough. Let me know if there is any clarification needed.

I’ve continued to look for an answer and found that my problem is I can have two DataContext in on statement. I’m not even sure if this would work if it wasn’t two DataContext but I tried doing this:

public static IEnumerable GetAPCBundledCodesData(string CPTCode)
    {

        var result = (from mod in new VADataContext().MODIFIERs
                      join cpt2mod in new VADataContext().CPT2MODs on mod.MOD equals cpt2mod.MOD
                      where cpt2mod.CPT == CPTCode
                      select new { mod.MOD, mod.SHORT }).ToList();
        return result;
    }

This resulted in an error saying I can’t pull data from two different sources. Is there a different way to handle it?

Here is some sample data to show what is going on here.

Table CPT2MOD

CPT**   MOD**
31624   TC
31624   A
31624   DC
99213   B
99213   T
00100   AS

Table MODIFIERs

MOD**   SHORT**
TC      TC Desc
A       A Desc
DC      DC Desc
B       B Desc
T       T Desc
AS      AS Desc

A CPT Code will be passed to GetAPCBundledCodesData (ex 99213) and it will look for all MOD values associated with it from the CPT2MOD table (B, T). Then it will return those MOD from the MODIFIERs table along with the description. (B, B Desc; T, T Desc).

I hope you can see what I am asking better now.

Solution

public static IEnumerable GetAPCBundledCodesData(string CPTCode)
        {
            using (var dc = new VADataContext()){
            var result = (from a in dc.CPT2MODs
                          where a.CPT == CPTCode
                          join b in dc.MODIFIERs on a.MOD equals b.MOD
                          select new { b.MOD, b.SHORT }).ToList();
            return result;
            }
        }
  • 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-10T13:10:50+00:00Added an answer on June 10, 2026 at 1:10 pm

    Use only one ObjectContext – and use a using (very important):

    using(var dc = new VADataContext()){
      var result = (from mod in dc.MODIFIERs 
                      join cpt2mod in dc.CPT2MODs on mod.MOD equals cpt2mod.MOD 
                      where cpt2mod.CPT == CPTCode 
                      select new { mod.MOD, mod.SHORT }).ToList(); 
      return result; 
    }
    

    As an aside – entity framework typically doesn’t call the classes it generates DataContext – that’s a Linq to SQL thing – are you sure that you’re actually using entity framework? It doesn’t actually have any bearing on the fix, it’s just a request for clarification.

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

Sidebar

Related Questions

To begin with: Using Entity Framework v4.0. ASP.NET MVC 2.0. Visual Studio 2010. I
I create a ASP.net MVC 4 project by using Visual Studio 2010 IDE. I
I am currently developing an ASP.NET MVC 3 site using Visual Studio 2010 with
I'm going to be building some ASP.Net MVC 2 software using Visual Studio 2010
I have existing project in Visual Studio 2010, ASP.NET MVC 3 with existing database
I am using ASP.NET MVC 2 in Visual Studio 2010. In my project I
I am using ASP.NET MVC 2 with Visual Studio 2010. A lot of my
I am using Visual Studio 2010 with MVC 3 and MS SQL SERVER 2008
I am using Visual Studio 2010 / ASP.net MVC 3 with the Razor View
I'm currently using Visual Studio 2010 and have created a 'ASP.NET MVC 3 Web

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.