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

The Archive Base Latest Questions

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

Here the code which i have written, I am getting error as soon as

  • 0

Here the code which i have written, I am getting error as soon as i added the line to call the second function which is ValidCodes = GetValidCodes(bv.Variable_Id)

public IQueryable<BvIndexRow> GetBenefitVariableIndex(int healthPlanId)
{
    var q = from bv in Db.BenefitVariables
            where bv.Private == "N" || (bv.Private == "Y" && bv.Health_Plan_ID == healthPlanId)
            join bao in Db.baObject on bv.Variable_Id equals bao.ba_Object_id
            join servicetype in Db.BenefitVariableServiceTypes.Where(bvst => bvst.Key_Service_Type == "Y" && bvst.isActive == 1) 
            on bv.Variable_Id equals servicetype.Variable_Id into groupedBvst
            where bv.isActive == 1 && bao.isActive == 1 
            from bvst in groupedBvst.DefaultIfEmpty()
            select new BvIndexRow
            {
                // some code here too
                ValidCodes = GetValidCodes(bv.Variable_Id)
            };
    return q;
}

public string GetValidCodes(int varID)
{
    // some code here
    return "None";
}
  • 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-25T21:16:13+00:00Added an answer on May 25, 2026 at 9:16 pm

    Another poster has answered why, but not what to do. The why is that the method call cannot be translated by Linq-to-SQL into SQL, as it’s… not part of SQL! This makes perfect sense! So an easy way to fix this is:

    public IQueryable<BvIndexRow> GetBenefitVariableIndex(int healthPlanId)
    {
       var q = (... your query ...
          select new BvIndexRow
          {
             Type = (bv.Private.ToLower() == "y" ? "Private " : "Public ") + (bao.ba_system_variable_ind ? "System" : "Benefit"),
             Class = bv.Variable_Classification,
             ServiceType = bvst.Service_Type.Service_Type_Name ?? string.Empty,
             LineOfBusiness = bv.LOB,
             Status = bv.Status.ToLower() == "p" ? "Production" : "Test",
             Name = bao.ba_object_Code,
             Description = bao.ba_Object_Desc,
             Id = bv.Variable_Id,
          }).ToArray();
    
       foreach (var bvIndexRow in q) {
          bvIndexRow.ValidCodes = GetValidCodes(bvIndexRow .Variable_Id);
       }
    
       return q;
    }
    

    This should give you want you want!

    EDIT: By the by, you probably also want to call .ToList() or .ToArray() on your list of BvIndexRows. This has the effect of causing immediate evaluation and will prevent a multiple enumeration. If you don’t want immediate evaluation you may need to edit your question to explain why that’s the case. I’ve added a .ToArray() to the example above, but I also wanted to explain why!

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

Sidebar

Related Questions

I have some code here which works perfectly in firefox but not in chrome
I have this code here, which is intended to allow any type of arguments:
I have the following code, which compiles but doesn't bring back any data. Here
I have written some code in which a small part of the code takes
I am creating my own jQuery plugin. Here is the code which I have
I have written a piece of code which writes either to console or to
Hey Folks,I have pasted my code here. Dialog.inform contains a 'long' value which is
Here is jquery code which hides my table cells with the ID of .style2:
Here is my code which checks if the file exists : #include<stdio.h> #include<zlib.h> #include<unistd.h>
Here is my code which is doing the conversion from hex to decimal. The

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.