C# (CSharp) BlogEngine.Core.Providers DbConnectionHelper - 7 ejemplos encontrados. Estos son los ejemplos en C# (CSharp) del mundo real mejor valorados de BlogEngine.Core.Providers.DbConnectionHelper extraídos de proyectos de código abierto. Puedes valorar ejemplos para ayudarnos a mejorar la calidad de los ejemplos.
This class is meant to reduce the amount of repeated code in database provider classes by pulling all the common actions into one spot. This should remove the many repetitive null checks on connections/parameters. This class handles the creation of DbConnection, setting its connection string, and opening the connection if possible. Usage is simple: using(var helper = new ConnectionHelper(provider)) { if (helper.HasConnection) { // do stuff } } Note: This class throws a NullReferenceException if its Provider.CreateParameter() method returns a null object. All of the methods in the DbBlogProvider class require parameterized queries, and previously each parameter created was being checked for null before proceeding. It's better to fail fast in this instance, to help creaters of custom implementations figure out what's wrong.