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

  • Home
  • SEARCH
  • 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 4000228
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:45:20+00:00 2026-05-20T07:45:20+00:00

We have a stored procedure that has a select statement in it: select convert(int,

  • 0

We have a stored procedure that has a select statement in it:

select convert(int, c.ID) as ID,
       convert(nvarchar(255), c.name) as name,
       convert(varchar(32), a.state) as state
from   customer c join address a on
       c.addressid = a.ID
where  c.name like @custNameSpec

This produces two records when executed in a T-SQL window:

ID  Name    State
1   Robert  PA
2   Rob     VA

When executed in Entity Framework 4 as a function import, it returns two records, but the first record is duplicated:

ID  Name    State
1   Robert  PA
1   Robert  PA

We deleted the function import and the imported function, recreated it, etc. We also added those SQL convert() statements above to guarantee Entity Framework understands the data types coming back from the server.

What could we do to fix it? What causes duplicates like that?

Our tests include:

var myresult3 = myUOW.DC.GetAdDir(todaysdate: null, store_nbr: 14, 
                                  adtype: null).ToList();
var myresult4 = DB.GetAdDir(todaysdate: null, store_nbr: 14, 
                            adtype: null).ToList();

Both return the same incorrect result. The SQL profiler shows this call:

exec [dbo].[GetCust] @todaysdate=NULL,@custNameSpec='Rob',@adtype=NULL

EDIT:

Apparently, the business rules changed. The POCO generated from Entity Framework had a primary key improperly set, so it returned the correct quantity of fields, but “removed” duplicates by making all duplicates the same (based on the POCO primary key fields.)

There was MergeOption referenced in other remotely related questions that may explain why this happens.

  • 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-20T07:45:21+00:00Added an answer on May 20, 2026 at 7:45 am

    When you create a unique restriction on an Entity, like a primary key, and you have duplicates coming from the data, Entity Framework will repeat the first duplicate record for all fields for each duplicate found.

    In other words, Entity Framework returns a mangled mess if your underlying data doesn’t reflect the primary key correctly.

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

Sidebar

Related Questions

I have a stored procedure that consists of a single select query used to
I have a stored procedure that returns values from a temp table. In my
I have a stored procedure that needs to convert hexadecimal numbers to their decimal
I have a stored procedure that returns two int Values. The first can not
I have a strange, sporadic issue. I have stored procedure that returns back 5
I have a stored procedure that returns multiple tables. How can I execute and
I have a stored procedure that looks like: CREATE PROCEDURE dbo.usp_TestFilter @AdditionalFilter BIT =
I have a Stored Procedure that rolls-back a series of operations. I want to
I have a stored procedure that ideally should be able to accept a list/table
Suppose I have a stored procedure that manages its own transaction CREATE PROCEDURE theProc

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.