diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2009-11-27 12:10:03 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2009-11-27 12:10:03 -0700 |
commit | 0ed1e01369d918ad828fa64728f89f9d2c675fdb (patch) | |
tree | 85ac9fb81153d6b8fb3774046f4fc28ab3f5df1f /projecttemplates/RelyingPartyLogic/Utilities.cs | |
parent | 1243c92a0172784f32938a2081f76463f90f102d (diff) | |
parent | 3d0b19ba07c1044b433d97e90ffe0489fee967dc (diff) | |
download | DotNetOpenAuth-0ed1e01369d918ad828fa64728f89f9d2c675fdb.zip DotNetOpenAuth-0ed1e01369d918ad828fa64728f89f9d2c675fdb.tar.gz DotNetOpenAuth-0ed1e01369d918ad828fa64728f89f9d2c675fdb.tar.bz2 |
Merge branch 'master' into extensibleDiscovery
Conflicts:
src/DotNetOpenAuth/OpenId/ProviderEndpointDescription.cs
Diffstat (limited to 'projecttemplates/RelyingPartyLogic/Utilities.cs')
-rw-r--r-- | projecttemplates/RelyingPartyLogic/Utilities.cs | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/projecttemplates/RelyingPartyLogic/Utilities.cs b/projecttemplates/RelyingPartyLogic/Utilities.cs index affbe26..5c9ae52 100644 --- a/projecttemplates/RelyingPartyLogic/Utilities.cs +++ b/projecttemplates/RelyingPartyLogic/Utilities.cs @@ -7,6 +7,10 @@ namespace RelyingPartyLogic { using System; using System.Collections.Generic; + using System.Data; + using System.Data.Common; + using System.Data.EntityClient; + using System.Data.Objects; using System.Globalization; using System.IO; using System.Linq; @@ -17,7 +21,7 @@ namespace RelyingPartyLogic { using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.Smo; - public class Utilities { + public static class Utilities { internal const string DefaultNamespace = "RelyingPartyLogic"; /// <summary> @@ -61,6 +65,31 @@ GO } } + /// <summary> + /// Executes a SQL command against the SQL connection. + /// </summary> + /// <param name="objectContext">The object context.</param> + /// <param name="command">The command to execute.</param> + /// <returns>The result of executing the command.</returns> + public static int ExecuteCommand(this ObjectContext objectContext, string command) { + DbConnection connection = ((EntityConnection)objectContext.Connection).StoreConnection; + bool opening = (connection.State == ConnectionState.Closed); + if (opening) { + connection.Open(); + } + + DbCommand cmd = connection.CreateCommand(); + cmd.CommandText = command; + cmd.CommandType = CommandType.StoredProcedure; + try { + return cmd.ExecuteNonQuery(); + } finally { + if (opening && connection.State == ConnectionState.Open) { + connection.Close(); + } + } + } + internal static void VerifyThrowNotLocalTime(DateTime value) { // When we want UTC time, we have to accept Unspecified kind // because that's how it is set to us in the database. |