当前位置: 首页>>代码示例>>C#>>正文


C# IDbConnection.GetType方法代码示例

本文整理汇总了C#中IDbConnection.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IDbConnection.GetType方法的具体用法?C# IDbConnection.GetType怎么用?C# IDbConnection.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDbConnection的用法示例。


在下文中一共展示了IDbConnection.GetType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: JConnect

        public JConnect(IDbConnection connection)
        {
            this.connection = connection;
              commandTimeout = 30;
              Type type = connection.GetType();

              if (type == typeof(System.Data.Odbc.OdbcConnection))
              {
            typeOfParameter = ParameterType.QuestionMark;
            typeOfVendor = VendorType.Odbc;
              }
              else if (type == typeof(System.Data.OleDb.OleDbConnection))
              {
            typeOfParameter = ParameterType.QuestionMark;
            typeOfVendor = VendorType.OleDb;
              }
              else if (type == typeof(System.Data.SqlClient.SqlConnection))
              {
            typeOfParameter = ParameterType.AtSymbol;
            typeOfVendor = VendorType.SqlServer;
            GetReturningProc += new GetReturningHandler(SqlServerReturning);
              }
              else
              {
            typeOfParameter = ParameterType.Colon;
            typeOfVendor = VendorType.Oracle;
            GetReturningProc += new GetReturningHandler(OracleReturning);
              }
              GetTimeStampProc += new GetTimeStampHandler(DefaultGetTimeStampProc);
        }
开发者ID:VincentRisi,项目名称:jportal,代码行数:30,代码来源:Portal.cs

示例2: CloneDbConnection

		/// <summary>
		/// Clones a new DbConnection supported by this provider.
		/// </summary>
		/// <param name="connection">The connection to clone.</param>
		/// <returns>A new DbConnection.</returns>
		public override IDbConnection CloneDbConnection(IDbConnection connection)
		{
			if (connection == null) throw new ArgumentNullException("connection");

			var newConnection = (IDbConnection)System.Activator.CreateInstance(connection.GetType());
			newConnection.ConnectionString = connection.ConnectionString;
			return newConnection;
		}
开发者ID:EdWeller,项目名称:Insight.Database,代码行数:13,代码来源:WrappedInsightDbProvider.cs

示例3: ProfiledDbConnection

        public ProfiledDbConnection(IDbConnection connection, IDbProfiler profiler, bool autoDisposeConnection=true)
        {
    		var hasConn = connection as IHasDbConnection;
			if (hasConn != null) connection = hasConn.DbConnection;
    		var dbConn = connection as DbConnection;

			if (dbConn == null)
				throw new ArgumentException(connection.GetType().GetOperationName() + " does not inherit DbConnection");
			
			Init(dbConn, profiler, autoDisposeConnection);
        }
开发者ID:jin29neci,项目名称:ServiceStack,代码行数:11,代码来源:ProfiledDbConnection.cs

示例4: ProfiledDbConnection

    	public ProfiledDbConnection(IDbConnection connection, IDbProfiler profiler)
    	{
    		var hasConn = connection as IHasDbConnection;
			if (hasConn != null) connection = hasConn.DbConnection;
    		var dbConn = connection as DbConnection;

			if (dbConn == null)
				throw new ArgumentException(connection.GetType().Name + " does not inherit DbConnection");
			
			Init(dbConn, profiler);
        }
开发者ID:austinvernsonger,项目名称:ServiceStack,代码行数:11,代码来源:ProfiledDbConnection.cs

示例5: CloseConnection

 public virtual void CloseConnection(IDbConnection conn)
 {
     try
     {
         conn.Close();
     }
     catch
     {
         throw new Exception("Could not close " + conn.GetType() + " connection");
     }
 }
开发者ID:eicrosoft,项目名称:VipSoft,代码行数:11,代码来源:ConnectionProvider.cs

示例6: ReplacePrefixParameter

 /// <summary>
 /// 根据不同数据库加前缀
 /// </summary>
 /// <param name="cnn">连接</param>
 /// <param name="sql">sql语句</param>
 /// <returns>替换后的sql</returns>
 public static string ReplacePrefixParameter(IDbConnection cnn, string sql)
 {
     if (!string.IsNullOrEmpty(sql))
     {
         if (cnn.GetType().ToString().ToLowerInvariant().Contains("oracle"))
         {
             sql = sql.Replace('@', ':');
         }
     }
     return sql;
 }
开发者ID:huoxudong125,项目名称:Slickflow,代码行数:17,代码来源:DefaultParameterCharacter.cs

示例7: CloseConnection

		/// <summary>
		/// Closes the <see cref="IDbConnection"/>.
		/// </summary>
		/// <param name="conn">The <see cref="IDbConnection"/> to clean up.</param>
		public virtual void CloseConnection(IDbConnection conn)
		{
			log.Debug("Closing connection");
			try
			{
				conn.Close();
			}
			catch (Exception e)
			{
				throw new ADOException("Could not close " + conn.GetType() + " connection", e);
			}
		}
开发者ID:tkellogg,项目名称:NHibernate3-withProxyHooks,代码行数:16,代码来源:ConnectionProvider.cs

示例8: DataBaseObjects

 public DataBaseObjects(IDbConnection conn, IEnumerable<ITableFilter> tablesToGenerate,
                        IEnumerable<ITableFilter> columnsToGenerate)
 {
     _conn = conn;
     var tablefilters= new List<ITableFilter>();
     if (_conn.GetType().Name.StartsWith("Npgsql",StringComparison.InvariantCultureIgnoreCase))
     {
          tablefilters.Add(new PostgresTableFilter());
     }
     InitPublicTables(tablefilters.Union(tablesToGenerate??new ITableFilter[0]),
                      columnsToGenerate);
 }
开发者ID:wallymathieu,项目名称:mejram,代码行数:12,代码来源:DataBaseObjects.cs

示例9: DesignConnection

 public DesignConnection(string connectionName, IDbConnection conn)
 {
     this.properties = new HybridDictionary();
     this.modifier = MemberAttributes.Assembly;
     if (conn == null)
     {
         throw new ArgumentNullException("conn");
     }
     this.name = connectionName;
     DbProviderFactory factoryFromType = ProviderManager.GetFactoryFromType(conn.GetType(), ProviderManager.ProviderSupportedClasses.DbConnection);
     this.provider = ProviderManager.GetInvariantProviderName(factoryFromType);
     this.connectionStringObject = new System.Data.Design.ConnectionString(this.provider, conn.ConnectionString);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:13,代码来源:DesignConnection.cs

示例10: GetCollection

 private DataTable GetCollection(IDbConnection conn, string colName)
 {
     var conType = conn.GetType();
       var method = conType.GetMethod("GetSchema", new Type[] {typeof(string)});
       try {
     conn.Open();
     var result = method.Invoke(conn, new object[] { colName });
     var dt = (DataTable)result;
     return dt;
       } finally {
     conn.Close();
       }
 }
开发者ID:yuanfei05,项目名称:vita,代码行数:13,代码来源:GetSchemaTests.cs

示例11: GetDatabaseType

 public static DatabaseType GetDatabaseType( IDbConnection cn ) {
     if (cn is OleDbConnection) {
         return DatabaseType.Access;
     }
     if (cn is SqlConnection) {
         return DatabaseType.SqlServer;
     }
     if (cn.GetType() == MysqlFactory.mySqlConnectionType) {
         return DatabaseType.MySql;
     }
     if (cn is OracleConnection) {
         return DatabaseType.Oracle;
     }
     return DatabaseType.Other;
 }
开发者ID:2014AmethystCat,项目名称:wojilu,代码行数:15,代码来源:DbTypeChecker.cs

示例12: GetProvider

        /// <summary>
        /// Gets a dialect provider based on the <see cref="connection"/>
        /// </summary>
        /// <param name="connection">Connection to get a dialect provider from</param>
        public static DbLiteDialectProvider GetProvider(IDbConnection connection)
        {
            if (connection == null)
                throw new ArgumentNullException(nameof(connection));

            var connectionType = connection.GetType();

            DbLiteDialectProvider provider;
            if (!dialectProviders.TryGetValue(connectionType.FullName, out provider))
            {
                throw new DialectProviderNotRegisteredException($"No dialect provider with the name \"{connectionType.FullName}\" are registered.");
            }

            return provider;
        }
开发者ID:NsdWorkBook,项目名称:DbLite,代码行数:19,代码来源:DbLiteDialectProviderFactory.cs

示例13: Get

        /// <summary>
        /// Provides an IDbParser based on the DB connection type.
        /// </summary>
        /// <param name="connection"></param>
        /// <returns></returns>
        public static IDbParser Get(IDbConnection connection)
        {
            Type typeConnection = connection.GetType();
            switch (typeConnection.FullName)
            {
                case "System.Data.SqlClient.SqlConnection": // MS SQL
                case "Npgsql.NpgsqlConnection": // PostgreSQL
                case "MySql.Data.MySqlClient.MySqlConnection": // MySQL
                case "System.Data.SQLite.SQLiteConnection": // SQLite
                    return new InformationSchemeSupported();

                case "IBM.Data.DB2.iSeries.iDB2Connection":
                default:
                    throw new Exception(String.Format("The provided database connection type '{0}' seems to be an unsupported connection", typeConnection.FullName));
            }
        }
开发者ID:ZoolWay,项目名称:DbNanites,代码行数:21,代码来源:Factory.cs

示例14: GetChanges

        public IAnalyzeResult GetChanges(IModelParseResult parsedModel, IDbConnection targetDatabase)
        {
            // check arguments
            if (parsedModel == null) throw new ArgumentNullException("parsedModel");
            if (targetDatabase == null) throw new ArgumentNullException("targetDatabase");
            if (!(parsedModel is IModel)) throw new Exception("Supplied parsed model does not satify internal requirements!");

            AnalyzeResult result = new AnalyzeResult();

            try
            {
                // analyze target database
                log.DebugFormat("Analyzing the target database '{0}' found in connection string '{1}', connection type is '{2}'", targetDatabase.Database, targetDatabase.ConnectionString, targetDatabase.GetType().FullName);
                Parsers.Database.IDbParser dbParser = Parsers.Database.Factory.Get(targetDatabase);
                SchemeDefinition dbDefinition = dbParser.RetrieveSchemeDefinition(targetDatabase);

                // compare
                IModel referenceModel = parsedModel as IModel;
                log.DebugFormat("Reference model: '{0}' ({1} tables)", referenceModel.Description, referenceModel.Scheme.Tables.Count);
                foreach (var modelTable in referenceModel.Scheme.Tables)
                {
                    log.DebugFormat("Checking reference table '{0}'", modelTable.Name);
                    var dbTable = dbDefinition.Tables.FirstOrDefault(t => t.Name == modelTable.Name);
                    if (dbTable != null)
                    {
                        // TODO compare with db table
                    }
                    else
                    {
                        // TODO add migrationt ask for table creation
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("Analysis failed with exception", ex);
                result.AddErrorMessage(ex.Message);
                result.Success = false;
            }

            return result;
        }
开发者ID:ZoolWay,项目名称:DbNanites,代码行数:42,代码来源:Analyzer.cs

示例15: IsCompatibleConnection

		public override bool IsCompatibleConnection(IDbConnection connection)
		{
			return typeof(OdbcConnection).IsSameOrParentOf(connection.GetType());
		}
开发者ID:Convey-Compliance,项目名称:linq2db,代码行数:4,代码来源:SapHanaOdbcDataProvider.cs


注:本文中的IDbConnection.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。