C# (CSharp) BlogEngine.Core.Providers DbConnectionHelper - 7 примеров найдено. Это лучшие примеры C# (CSharp) кода для BlogEngine.Core.Providers.DbConnectionHelper, полученные из open source проектов. Вы можете ставить оценку каждому примеру, чтобы помочь нам улучшить качество примеров.
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.