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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:07:49+00:00 2026-05-26T04:07:49+00:00

Say I have a stored procedure GetAddressInfo(addressId int, errorCode int output) . The stored

  • 0

Say I have a stored procedure GetAddressInfo(addressId int, errorCode int output). The stored procedure returns AddressLine1 and State if addressId matches a row in the database. If row is not found, then the error code is set to non-zero value AND no select statement is fired. So it would look like this:

if (valid address id) begin
    Set errorCode = 1
    return
end

select AddressLine1, State from ....

When I use EF 4.0 to call such stored procedure, I get an Entity Framework exception when address id is invalid. The exception mentions that column AddressLine1 was not part of the data reader.

I was expecting no results (no records) and output error code parameter set to 1. Instead, I’m getting exceptions. I simply want to stop processing the rest of the stored procedure and return immediately. Seems like this is not supported very well by EF 4.0.

Any ideas on this?

Thanks in advance!

  • 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-26T04:07:50+00:00Added an answer on May 26, 2026 at 4:07 am

    This is one of the prime arguments against stored procs – business logic starts to end up in them. Im not saying Im voting either way – just note what you are experiencing is a problem and makes it a bit more difficult to unit test.

    EF generally needs to know the fields that are being returned (depending how you have it mapped). How specifically are you calling this proc? directly on the context, or is it mapped to an entity operation (a select-read operation for example)

    If its mapped to a read operation, you need to change how you are doing this. Your column output list should be consistent.

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

Sidebar

Related Questions

Say I have a stored procedure that returns data from a SELECT query. I
Let's say I have a stored procedure in Microsoft SQL Server 2005 that returns
Let's say I have a stored procedure which returns a large set of data.
Say I have a stored procedure consisting of several separate SELECT, INSERT, UPDATE and
Let's say I have a simple stored procedure that looks like this (note: this
I have a stored procedure with multiple insert/select statements. Let's say I'm using the
I have a result set in MS-SQL within a stored procedure, and lets say
I have a stored procedure that has a bunch of input and output parameters
Say I have this great query in my stored procedure. Select * from Temp
I am using SQL Server 2005. I have a stored procedure [say Sp_GetAllMaterialInfo], I

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.