I understand that wrapping an IDbConnection object in a using block ensures that Dispose will get called and the resources it is using will get freed. That being said do I also need to wrap IDbCommand and IDataReader in using blocks as well, or is just wrapping the connection object sufficient. Thanks.
IDbConnection and using blocks in c#
959 Views Asked by jfin3204 At
2
There are 2 best solutions below
Related Questions in C#
- How to call a C language function from x86 assembly code?
- What does: "char *argv[]" mean?
- User input sanitization program, which takes a specific amount of arguments and passes the execution to a bash script
- How to crop a BMP image in half using C
- How can I get the difference in minutes between two dates and hours?
- Why will this code compile although it defines two variables with the same name?
- Compiling eBPF program in Docker fails due to missing '__u64' type
- Why can't I use the file pointer after the first read attempt fails?
- #include Header files in C with definition too
- OpenCV2 on CLion
- What is causing the store latency in this program?
- How to refer to the filepath of test data in test sourcecode?
- 9 Digit Addresses in Hexadecimal System in MacOS
- My server TCP doesn't receive messages from the client in C
- Printing the characters obtained from the array s using printf?
Related Questions in USING
- gcc-11 compiler problems with multiple inheritance and statement "using"
- Error in Using references with Blazor Client
- Using decltype for templated function declaration results in "conflict" when defining the templated function
- An alternative for C++ not allowing templated type aliases?
- Do I need both Dispose() and Complete() methods in a transaction to achieve a roll back in case of failure?
- Bing Search not getting my Title & Description tags in the search results using React JS (data-rh="true")
- no applicable method for 'filter' applied to an object of class "character"
- C# .NET Core - Will a disposable persist across a try/catch block when declared outside? Is this poor practice?
- My use of __str__() inside of another object's __str__() is not working
- Don't know how to use namespace of one project in another
- OpenXML - Use SpreadsheetDocument.Open in a static class to make a kinf of Excel library
- Using keyword with virtual inheritance in cpp
- How do I stop Visual Studio from adding random usings?
- Loop Inside a dotnet using stament
- Does a using namespace directive make names usable in inlined functions?
Related Questions in USING-STATEMENT
- Why type aliases in C# cannot be used in another alias?
- A "using" statement gets moved automatically outside of the namespace
- C# Razor using statements inconsistently require explicit curly brackets
- is it necessary to use using Dispose the connection , open and close connection if using DbContext dapper in MS access database on vb.net
- Identify the encompassing using block
- C# setting members from using statement
- How to properly separate API calls from File Storage Service in a Clean Architecture Pattern?
- Does using statement close all kinds of streams in it?
- When is a `using var` disposed? Is it out-of-scope as soon as possible or at the end of the block?
- why we use nested using statement in c#?
- using statement with fluent api will not call dispose if throw occurs in fluent method chain
- C# What is the point of the using statement?
- Why exiting "using" invokes unexpected Dispose()?
- Why is c# creating a file before any file stream is created?
- using statement for multiple assignments to the variable
Related Questions in IDBCONNECTION
- Do I need to use Dependency Injection with a simple IDbConnection
- How to mock static extension methods in Unit Test (c#)
- 'New' cannot be used on an interface
- How come this select statement returns 01/01/0001 and null, but only for a few columns?
- Issues faced during ServiceStack Ugrade from 3.9.71 to 5.9.2
- Why does commandTimeout raise SqlError in IDbConnection.Execute?
- Error trying to run ASE sql (sybase) on .net core web api "A request to send or receive data was disallowed ..."
- General SQL execution using IDBconnection
- .Net Core Dependency Injection IdbConnection
- Implement IDbConnection in .Net Core
- How can I prevent this code from disposing objects multiple times?
- Share IDbConnection to keep transaction local
- Dapper Hangs at Execute
- Proper way of using BeginTransaction with Dapper.IDbConnection
- How to best handle Sql connections in long running processes with Ninject?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
There are a number of easy ways to work out the answer to this for any given object without consulting the documentation:
usingblock and it's notIDisposable, you'll get a syntax error..Disposemethod (easily checked in Intellisense) then you should wrap it.IDisposable(easily checked through "go to definition" or the new "peek" functionality in VS) you should wrap it.Alternatively, by way of example, you can see from the MSDN docs that
IDbCommandimplementsIDisposableand therefore should be disposed of with ausingblock.