logo
down
shadow

Cancel a stored procedure called from Entity framework


Cancel a stored procedure called from Entity framework

By : user2948735
Date : November 15 2020, 06:54 AM
I wish this helpful for you Entity Framework 6 has the ExecuteSqlCommandAsync method that supports use cancellation tokens which can be used to cancel the task in the normal way, e.g.
code :
var token = new CancellationTokenSource();
var t = db.Database.ExecuteSqlCommandAsync("WAITFOR DELAY '00:00:15'", token.Token);
// you can now use `token.Cancel` to cancel the SP.
t.Wait();


Share : facebook icon twitter icon
MySQL and Entity Framework - Application calling a stored procedure returns 0 rows effected but the same procedure works

MySQL and Entity Framework - Application calling a stored procedure returns 0 rows effected but the same procedure works


By : Đức Việt
Date : March 29 2020, 07:55 AM
I hope this helps . I discovered what was causing the problem but I don't really understand why. If someone gives a good explanation then I will accept that as the answer to this question rather than accepting my own.
This is what appears to have caused the problem.
code :
CREATE PROCEDURE LogResponse(IN myVals)
BEGIN 
Insert Into `DevDB`.`tblResponses`
(
    someValueNames
)
Values
(
    someValues
);

 SELECT LAST_INSERT_ID() As NewResponseId;
END
SELECT SCOPE_IDENTITY() As NewResponseId
SELECT LAST_INSERT_ID() As NewResponseId;
Entity Framework shows error when called stored procedure

Entity Framework shows error when called stored procedure


By : Sriram Ramadoss Venk
Date : March 29 2020, 07:55 AM
With these it helps The error tells us that EF is expecting a result set and when we use RETURN we don't get a result set. Your error means that the stored procedure is returning an integer but EF is expecting a decimal, so we just CAST the selected values to a decimal.
So modify the SQL so that we SELECT instead of RETURN, like so (not forgetting to use CAST):
code :
 IF EXISTS (Select cntct_ctr_phn_ln_id
                from dbo.cntct_ctr_phn_ln
                where
                [toll_free_phn_area_cd] = @TollfreeareaCode and
                [toll_free_phn_prfx_no] = @TollfreePrfxNo and
                [toll_free_phn_sfx_no] = @TollfreeSfxNo)
                SELECT CAST(1 AS decimal)
SELECT CAST(SCOPE_IDENTITY() AS decimal)
Stored procedure is executing with different indexes when called via Entity Framework compared to SSMS

Stored procedure is executing with different indexes when called via Entity Framework compared to SSMS


By : user3100134
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , I found the answer: I focused two much on entity framework, but when I widened my search I found answers about ADO.NET using different settings on the connection, therefore using a different execution plan: Why is some sql query much slower when used with SqlCommand?
Stored Procedure error when called from Entity Framework

Stored Procedure error when called from Entity Framework


By : MEP
Date : March 29 2020, 07:55 AM
I wish this help you You don't need the N'...' wrap in your code, that's only a SQL Server thing for unicode conversion. For example, see this. So when you're doing that, you're actually passing the package name of N'CalculateReports.dtsx' which obviously doesn't exist.
Instead, do this Value = "CalculateReports.dtsx", for example:
code :
cmd.Parameters.Add(new SqlParameter("@package_name1", SqlDbType.NVarChar)
{
    Value = "CalculateReports.dtsx"
});
cmd.Parameters.Add(new SqlParameter("@folder_name1", SqlDbType.NVarChar)
{
    Value = "SSIS projects"
});
cmd.Parameters.Add(new SqlParameter("@project_name1", SqlDbType.NVarChar)
{
    Value = "CalculateReports.dtsx"
});
cmd.Parameters.Add(new SqlParameter("@param1", SqlDbType.NVarChar)
{
    Value = "2017-04-01 00:00:00"
});
cmd.Parameters.Add(new SqlParameter("@param1name", SqlDbType.NVarChar)
{
    Value = "startDate"
});
Is stored procedure with Entity framework good design or have to write direct queries on front end (no stored procedure)

Is stored procedure with Entity framework good design or have to write direct queries on front end (no stored procedure)


By : jax
Date : March 29 2020, 07:55 AM
around this issue EF doesn't negate the values of a stored procedure, EF makes adhoc queries easier to perform as well as updates etc... Stored procedures are still very useful, stored procs allow you to change logic/criteria without having to recompile the .NET code, from my experience EF makes life easier when you need to do a lookup on a foreign key etc but it is converted into a T-SQL statement.
Like everything it all depends, if you are in an environment where stored procedures are the norm then EF will work fine, however if you free to perform adhoc queries then EF expressions are great. There is no right or wrong here, EF probably makes the number of stored procedures smaller but sometimes stored procedures are exactly what you should do.
Related Posts Related Posts :
  • Marshal.Copy attempted to read or write protected memory At Random Times
  • Restrict Type variable to specific class or subclass
  • Horizontal text alignment in a PdfPCell
  • C# crashing with Form.show() command, ObjectDisposedException - Deeper look / explanation please
  • Will the result of a LINQ query always be guaranteed to be in the correct order?
  • "Could not find default endpoint element that references contract"
  • Umbraco Request.QueryString is null if it's the first time the page is loaded
  • Error inconsistent accessibility method C#
  • How to program Intel Xeon Phi with C#?
  • remove nested element using regular expression
  • Is there a C# alternative to Java's vararg parameters?
  • Clear particular column values in DataTable
  • how to add event handler to programatically created checkboxes
  • Cannot apply indexing with [] to an expression of type 'System.Collections.Specialized.NameValueCollection'
  • Check for key in pre-existing dictionary in case insensitive manner
  • How to remove year from datetime object?
  • Accessing Settings in different ways
  • "This project is empty" error in Sonarqube
  • How to create reusable icon menu in Xamarin
  • Value Cannot be null in Ado.Net connectivity
  • Adding a custom/dynamic attribute when using XSD.exe
  • How to convert object to correct type
  • Automatically sign out from Forms Authentication in ASP.NET when browser is closed
  • Can a WCF service support both Buffered and Streamed transfer modes?
  • Verify a CA Certificate with a public key in C#
  • How to invoke a Web Service that requires the "patch" verb using the C# WebClient wrapper?
  • Proper way a implementing property based on generic type
  • Closing a form that is created in another thread
  • How Can You Bind a List<String> to a StackPanel
  • WPF Application Update Best Practices - Architectural Explanation
  • System.UnauthorizedAccessException in Server.MapPath()
  • Connecting and Using SQL Compact Edition in a WPF application
  • C#: weird ref in constructor to behave like "virtual field"
  • C# XDocument Load with multiple roots
  • How to decide what goes in the Domain or Application Project in a "DDD" solution?
  • How to get/set a property of an interface that is not always implemented
  • Read-only array field in unsafe struct
  • i got "Invalid attempt to call Read when reader is closed" when using sqldatareader how to solve it in a three
  • Why should I encapsulate objects in using if there is garbage collection
  • How to load Word document from byte array
  • Caliburn.Micro and ContextMenu for DataGrid Row
  • Linq "join" with a IList<T> getting "Error Unable to create a constant value.."
  • How to draw red wavy line under words in RichTextBox c# winform
  • HttpPostedFileBase returns Null MVC3
  • Refresh Dropdownlist in webform
  • How to convert serialized byte array back to its text form
  • How to do a loop to check all the variables at the same time for C#?
  • Facebook Sentiment Analysis API
  • Counting occurrences of specific letters in string
  • Module 'System.Data.Linq' Version=4.0.0.0, Culture=neutral, Publickeytoken=b77a5c561934e089' should be referenced
  • C# MVC Dynamically create view model
  • Get Executing Path of C# application when using nunit with Jenkins
  • GDI count stable near 100 but Handle count keep increasing
  • Problem adding string value to ViewBag from an MVC Action using TempData
  • Reading Excel file on condition
  • what is windows programming from C++, C# and Java perspective?
  • How to deal with C# object references in MongoDB?
  • How to create a list from filtering 2 lists with linq to object
  • Webclient calls to DownloadString cause my app to freeze
  • How to create a JSON WebService in c# ASP.Net with a valid JSON output and query with JQuery/Ajax
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org