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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:06:44+00:00 2026-06-15T14:06:44+00:00

I am trying to call a stored procedure with Linq, the stored procedure returns

  • 0

I am trying to call a stored procedure with Linq, the stored procedure returns the value fine in SQL, but when I drag it onto my DBML file and try and call it from my code it is returning the

Could not find an implementation of the query pattern for source type ‘int’. ‘Select’ not found.

I’ve looked at other threads and other stored procedures I have and for some reason rather than using an ISingleResult this is different and I cant seem to change the Return Type either.

This is the DBML code behind

[global::System.Data.Linq.Mapping.FunctionAttribute(Name="dbo.displayDetails")]
public int displayDetails([global::System.Data.Linq.Mapping.ParameterAttribute(DbType="VarChar(1)")] string sex, [global::System.Data.Linq.Mapping.ParameterAttribute(DbType="Int")] System.Nullable<int> day, [global::System.Data.Linq.Mapping.ParameterAttribute(DbType="Int")] System.Nullable<int> month, [global::System.Data.Linq.Mapping.ParameterAttribute(DbType="Int")] System.Nullable<int> year, [global::System.Data.Linq.Mapping.ParameterAttribute(Name="PostCode", DbType="VarChar(10)")] string postCode, [global::System.Data.Linq.Mapping.ParameterAttribute(Name="AppTime", DbType="DateTime")] System.Nullable<System.DateTime> appTime, [global::System.Data.Linq.Mapping.ParameterAttribute(DbType="Int")] System.Nullable<int> filter)
{
        IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), sex, day, month, year, postCode, appTime, filter);
        return ((int)(result.ReturnValue));
}

My page code which is getting the error

    var person = from p in db.displayDetails(sex.ToString(),
                  Convert.ToInt32(dayOfBirth),
                  Convert.ToInt32(monthOfBirth),
                  Convert.ToInt32(yearOfBirth),
                  postCode.ToString(),
                  Convert.ToDateTime(appointmentTime),
                  Convert.ToInt32(resultType))
                  select person;
        {
            p.Forename,
            p.Surname,
            p.AppointmentTime,
            p.Location
        };

        foreach (var record in person)
        {
            lblName.Text = record.Forename + " " + record.Surname;
            lblAppointmentTime.Text = record.AppointmentTime.ToString();
            lblWaitIn.Text = record.Location;
        }   

Any help on how to get this resolved would be appreciated.

Update – Hi, here is my SP:

@sex varchar (1),
@day int,
@month int,
@year int,
@PostCode varchar (10),
@AppTime DateTime,
@filter int

AS
BEGIN

declare @sql nvarchar(max)
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    -- Insert statements for procedure here

Select @Sql = 'SELECT DAY(DateOfBirth) AS DayOfBirth, MONTH(DateOfBirth) AS MonthOfBirth, 
YEAR(DateOfBirth) AS YearOfBirth, DateOfBirth, Sex, AppointmentTime, SchdlRefno, Forename, 
Surname, ClinicCode, Ur, PostCode, Specialty, Location
FROM dbo.tbl_Appointments'


if @filter  = 1
-- show search by just sex, day and month as no more needed for match
Select @sql = @Sql + ' WHERE (DAY(DateOfBirth) = ' + convert(varchar, @day, 103) + ') AND (MONTH(DateOfBirth) = ' + convert(varchar, @month, 103) + ') AND (Sex = ''' + @sex + ''')' 

if @filter  = 2

-- show search by sex, day and month and postcode

Select @sql = @Sql + ' WHERE (DAY(DateOfBirth) = ' + convert(varchar, @day, 103) + ') AND (MONTH(DateOfBirth) = ' + convert(varchar, @month, 103) + ') and (YEAR(DateOfBirth) = ' + convert(varchar, @year, 103) + ') AND (Sex = ''' + @sex + ''') and (postcode = ''' + @postcode + ''')' 

if @filter  = 3

-- show search by sex, day and month, postcode and appointment time

Select @sql = @Sql + ' WHERE (DAY(DateOfBirth) = ' + convert(varchar, @day, 103) + ') AND (MONTH(DateOfBirth) = ' + convert(varchar, @month, 103) + ') and (YEAR(DateOfBirth) = ' + convert(varchar, @year, 103) + ') AND (Sex = ''' + @sex + ''') and (postcode = ''' + @postcode + ''') and (AppointmentTime = ''' + convert(varchar, @AppTime, 121) + ''')' 

print @sql  

Exec sp_executesql  @sql

END

So, im passing a filter through to bring back different search results.

Thanks

  • 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-15T14:06:45+00:00Added an answer on June 15, 2026 at 2:06 pm

    The problem is the result of your function isn’t a collection, it’s a scalar value (int) therefore can’t be projected.

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

Sidebar

Related Questions

I'm trying to call an Oracle Stored Procedure which returns XMLType data, but all
I'm trying to call a stored procedure that accepts a table value parameter. I
I am using Linq to SQL to call a stored procedure which runs a
I'm trying to call a parameterized stored procedure from SQL Server 2005 in my
I am trying to call a stored procedure from a select statement but it
I am trying to call a SQL Server stored procedure from my Python code,
I'm trying to call a stored procedure (on a SQL 2005 server) from C#,
I am new to Linq and trying to convert this SQL Server stored procedure
I'm trying to call a stored procedure using Hibernate, but I'm getting the following
Am trying to get linq to call a stored procedure. I know this is

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.