C# Entity Framework is throwing an error on ExecuteFunction
Quick update, I went through line by line, seeing the "function evaluation requires all threads to run".
Trying to execute a stored procedure using Entity Framework in C#. I have been successful in doing this for a SELECT
statement inside a stored procedure, but not so much with an UPDATE
.
I have verified the following:
- The stored procedure works in SQL Server with the values I am feeding it manually
- The stored procedure expects
bigint
as parameters, and thus the input is sent as INT64.
The method I assume the EF built around the stored procedure, gets through all parts except its return statement, where I get a rather general invalidexception error.
Any thoughts on this? I can provide a bit of the stored procedure and the line on the method:
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("SP_HERE", int64, int64, int64, int64);
}
Here is the stored procedure:
CREATE PROCEDURE some_SP
@var1 bigint,
@var2 bigint,
@var3 bigint,
@var4 bigint
AS
BEGIN
--SET NOCOUNT ON;
Then various update statements, this I pasted was the original create.
Any tips off the top of your heads would be helpful. Not sure what is causing this, and digging into the exception doesn't seem to yield anything helpful.
Thanks guys!
c# sql-server entity-framework
|
show 4 more comments
Quick update, I went through line by line, seeing the "function evaluation requires all threads to run".
Trying to execute a stored procedure using Entity Framework in C#. I have been successful in doing this for a SELECT
statement inside a stored procedure, but not so much with an UPDATE
.
I have verified the following:
- The stored procedure works in SQL Server with the values I am feeding it manually
- The stored procedure expects
bigint
as parameters, and thus the input is sent as INT64.
The method I assume the EF built around the stored procedure, gets through all parts except its return statement, where I get a rather general invalidexception error.
Any thoughts on this? I can provide a bit of the stored procedure and the line on the method:
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("SP_HERE", int64, int64, int64, int64);
}
Here is the stored procedure:
CREATE PROCEDURE some_SP
@var1 bigint,
@var2 bigint,
@var3 bigint,
@var4 bigint
AS
BEGIN
--SET NOCOUNT ON;
Then various update statements, this I pasted was the original create.
Any tips off the top of your heads would be helpful. Not sure what is causing this, and digging into the exception doesn't seem to yield anything helpful.
Thanks guys!
c# sql-server entity-framework
Possible duplicate of stackoverflow.com/questions/39062972/… and stackoverflow.com/questions/20901419/…
– Richard
Nov 27 '18 at 17:43
@Richard I wish :(. If you find anything referencing my update, though, let me know :).
– MZawg
Nov 27 '18 at 17:46
@MikeCMR - Are you returning anything from your stored proc? ExecuteFunction returns an Int32....per MSDN documentation, InvalidOperationException is thrown when there is a type mismatch between the reader and the function. Wondering if you are returning something other than the count of rows that is updated? Could that be what is causing the exception?
– user1011627
Nov 27 '18 at 17:49
@user1011627 good suggestion, but nope. Not returning anything. It can return an int it looks like, maybe rows affected? But that is not my goal. Just simply object db.stored_procedure(values), using it like a method.
– MZawg
Nov 27 '18 at 17:52
1
Maybe try and return @@ROWCOUNT and see if it works then...at least from a troubleshooting standpoint.
– user1011627
Nov 27 '18 at 17:53
|
show 4 more comments
Quick update, I went through line by line, seeing the "function evaluation requires all threads to run".
Trying to execute a stored procedure using Entity Framework in C#. I have been successful in doing this for a SELECT
statement inside a stored procedure, but not so much with an UPDATE
.
I have verified the following:
- The stored procedure works in SQL Server with the values I am feeding it manually
- The stored procedure expects
bigint
as parameters, and thus the input is sent as INT64.
The method I assume the EF built around the stored procedure, gets through all parts except its return statement, where I get a rather general invalidexception error.
Any thoughts on this? I can provide a bit of the stored procedure and the line on the method:
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("SP_HERE", int64, int64, int64, int64);
}
Here is the stored procedure:
CREATE PROCEDURE some_SP
@var1 bigint,
@var2 bigint,
@var3 bigint,
@var4 bigint
AS
BEGIN
--SET NOCOUNT ON;
Then various update statements, this I pasted was the original create.
Any tips off the top of your heads would be helpful. Not sure what is causing this, and digging into the exception doesn't seem to yield anything helpful.
Thanks guys!
c# sql-server entity-framework
Quick update, I went through line by line, seeing the "function evaluation requires all threads to run".
Trying to execute a stored procedure using Entity Framework in C#. I have been successful in doing this for a SELECT
statement inside a stored procedure, but not so much with an UPDATE
.
I have verified the following:
- The stored procedure works in SQL Server with the values I am feeding it manually
- The stored procedure expects
bigint
as parameters, and thus the input is sent as INT64.
The method I assume the EF built around the stored procedure, gets through all parts except its return statement, where I get a rather general invalidexception error.
Any thoughts on this? I can provide a bit of the stored procedure and the line on the method:
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("SP_HERE", int64, int64, int64, int64);
}
Here is the stored procedure:
CREATE PROCEDURE some_SP
@var1 bigint,
@var2 bigint,
@var3 bigint,
@var4 bigint
AS
BEGIN
--SET NOCOUNT ON;
Then various update statements, this I pasted was the original create.
Any tips off the top of your heads would be helpful. Not sure what is causing this, and digging into the exception doesn't seem to yield anything helpful.
Thanks guys!
c# sql-server entity-framework
c# sql-server entity-framework
edited Nov 27 '18 at 17:59
marc_s
580k13011191266
580k13011191266
asked Nov 27 '18 at 17:22
MZawgMZawg
959
959
Possible duplicate of stackoverflow.com/questions/39062972/… and stackoverflow.com/questions/20901419/…
– Richard
Nov 27 '18 at 17:43
@Richard I wish :(. If you find anything referencing my update, though, let me know :).
– MZawg
Nov 27 '18 at 17:46
@MikeCMR - Are you returning anything from your stored proc? ExecuteFunction returns an Int32....per MSDN documentation, InvalidOperationException is thrown when there is a type mismatch between the reader and the function. Wondering if you are returning something other than the count of rows that is updated? Could that be what is causing the exception?
– user1011627
Nov 27 '18 at 17:49
@user1011627 good suggestion, but nope. Not returning anything. It can return an int it looks like, maybe rows affected? But that is not my goal. Just simply object db.stored_procedure(values), using it like a method.
– MZawg
Nov 27 '18 at 17:52
1
Maybe try and return @@ROWCOUNT and see if it works then...at least from a troubleshooting standpoint.
– user1011627
Nov 27 '18 at 17:53
|
show 4 more comments
Possible duplicate of stackoverflow.com/questions/39062972/… and stackoverflow.com/questions/20901419/…
– Richard
Nov 27 '18 at 17:43
@Richard I wish :(. If you find anything referencing my update, though, let me know :).
– MZawg
Nov 27 '18 at 17:46
@MikeCMR - Are you returning anything from your stored proc? ExecuteFunction returns an Int32....per MSDN documentation, InvalidOperationException is thrown when there is a type mismatch between the reader and the function. Wondering if you are returning something other than the count of rows that is updated? Could that be what is causing the exception?
– user1011627
Nov 27 '18 at 17:49
@user1011627 good suggestion, but nope. Not returning anything. It can return an int it looks like, maybe rows affected? But that is not my goal. Just simply object db.stored_procedure(values), using it like a method.
– MZawg
Nov 27 '18 at 17:52
1
Maybe try and return @@ROWCOUNT and see if it works then...at least from a troubleshooting standpoint.
– user1011627
Nov 27 '18 at 17:53
Possible duplicate of stackoverflow.com/questions/39062972/… and stackoverflow.com/questions/20901419/…
– Richard
Nov 27 '18 at 17:43
Possible duplicate of stackoverflow.com/questions/39062972/… and stackoverflow.com/questions/20901419/…
– Richard
Nov 27 '18 at 17:43
@Richard I wish :(. If you find anything referencing my update, though, let me know :).
– MZawg
Nov 27 '18 at 17:46
@Richard I wish :(. If you find anything referencing my update, though, let me know :).
– MZawg
Nov 27 '18 at 17:46
@MikeCMR - Are you returning anything from your stored proc? ExecuteFunction returns an Int32....per MSDN documentation, InvalidOperationException is thrown when there is a type mismatch between the reader and the function. Wondering if you are returning something other than the count of rows that is updated? Could that be what is causing the exception?
– user1011627
Nov 27 '18 at 17:49
@MikeCMR - Are you returning anything from your stored proc? ExecuteFunction returns an Int32....per MSDN documentation, InvalidOperationException is thrown when there is a type mismatch between the reader and the function. Wondering if you are returning something other than the count of rows that is updated? Could that be what is causing the exception?
– user1011627
Nov 27 '18 at 17:49
@user1011627 good suggestion, but nope. Not returning anything. It can return an int it looks like, maybe rows affected? But that is not my goal. Just simply object db.stored_procedure(values), using it like a method.
– MZawg
Nov 27 '18 at 17:52
@user1011627 good suggestion, but nope. Not returning anything. It can return an int it looks like, maybe rows affected? But that is not my goal. Just simply object db.stored_procedure(values), using it like a method.
– MZawg
Nov 27 '18 at 17:52
1
1
Maybe try and return @@ROWCOUNT and see if it works then...at least from a troubleshooting standpoint.
– user1011627
Nov 27 '18 at 17:53
Maybe try and return @@ROWCOUNT and see if it works then...at least from a troubleshooting standpoint.
– user1011627
Nov 27 '18 at 17:53
|
show 4 more comments
1 Answer
1
active
oldest
votes
Return @@ROWCOUNT from the stored procedure. Most likely the issue you were experiencing is related to the mismatch between the type returned from the stored proc and the return value expected by the ExecuteFunction method.
Thanks again! I am going to dig around a bit to see why the @rows truly solved the issue, and update if I find anything. But glad its working.
– MZawg
Nov 27 '18 at 20:09
YW...please do....I dug a little to see if I could find out but never stumbled onto a real answer....would definitely like to know though.
– user1011627
Nov 27 '18 at 20:41
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53504980%2fc-sharp-entity-framework-is-throwing-an-error-on-executefunction%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Return @@ROWCOUNT from the stored procedure. Most likely the issue you were experiencing is related to the mismatch between the type returned from the stored proc and the return value expected by the ExecuteFunction method.
Thanks again! I am going to dig around a bit to see why the @rows truly solved the issue, and update if I find anything. But glad its working.
– MZawg
Nov 27 '18 at 20:09
YW...please do....I dug a little to see if I could find out but never stumbled onto a real answer....would definitely like to know though.
– user1011627
Nov 27 '18 at 20:41
add a comment |
Return @@ROWCOUNT from the stored procedure. Most likely the issue you were experiencing is related to the mismatch between the type returned from the stored proc and the return value expected by the ExecuteFunction method.
Thanks again! I am going to dig around a bit to see why the @rows truly solved the issue, and update if I find anything. But glad its working.
– MZawg
Nov 27 '18 at 20:09
YW...please do....I dug a little to see if I could find out but never stumbled onto a real answer....would definitely like to know though.
– user1011627
Nov 27 '18 at 20:41
add a comment |
Return @@ROWCOUNT from the stored procedure. Most likely the issue you were experiencing is related to the mismatch between the type returned from the stored proc and the return value expected by the ExecuteFunction method.
Return @@ROWCOUNT from the stored procedure. Most likely the issue you were experiencing is related to the mismatch between the type returned from the stored proc and the return value expected by the ExecuteFunction method.
answered Nov 27 '18 at 19:26
user1011627user1011627
1,2881118
1,2881118
Thanks again! I am going to dig around a bit to see why the @rows truly solved the issue, and update if I find anything. But glad its working.
– MZawg
Nov 27 '18 at 20:09
YW...please do....I dug a little to see if I could find out but never stumbled onto a real answer....would definitely like to know though.
– user1011627
Nov 27 '18 at 20:41
add a comment |
Thanks again! I am going to dig around a bit to see why the @rows truly solved the issue, and update if I find anything. But glad its working.
– MZawg
Nov 27 '18 at 20:09
YW...please do....I dug a little to see if I could find out but never stumbled onto a real answer....would definitely like to know though.
– user1011627
Nov 27 '18 at 20:41
Thanks again! I am going to dig around a bit to see why the @rows truly solved the issue, and update if I find anything. But glad its working.
– MZawg
Nov 27 '18 at 20:09
Thanks again! I am going to dig around a bit to see why the @rows truly solved the issue, and update if I find anything. But glad its working.
– MZawg
Nov 27 '18 at 20:09
YW...please do....I dug a little to see if I could find out but never stumbled onto a real answer....would definitely like to know though.
– user1011627
Nov 27 '18 at 20:41
YW...please do....I dug a little to see if I could find out but never stumbled onto a real answer....would definitely like to know though.
– user1011627
Nov 27 '18 at 20:41
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53504980%2fc-sharp-entity-framework-is-throwing-an-error-on-executefunction%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Possible duplicate of stackoverflow.com/questions/39062972/… and stackoverflow.com/questions/20901419/…
– Richard
Nov 27 '18 at 17:43
@Richard I wish :(. If you find anything referencing my update, though, let me know :).
– MZawg
Nov 27 '18 at 17:46
@MikeCMR - Are you returning anything from your stored proc? ExecuteFunction returns an Int32....per MSDN documentation, InvalidOperationException is thrown when there is a type mismatch between the reader and the function. Wondering if you are returning something other than the count of rows that is updated? Could that be what is causing the exception?
– user1011627
Nov 27 '18 at 17:49
@user1011627 good suggestion, but nope. Not returning anything. It can return an int it looks like, maybe rows affected? But that is not my goal. Just simply object db.stored_procedure(values), using it like a method.
– MZawg
Nov 27 '18 at 17:52
1
Maybe try and return @@ROWCOUNT and see if it works then...at least from a troubleshooting standpoint.
– user1011627
Nov 27 '18 at 17:53