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


C# DataConnection.Execute方法代码示例

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


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

示例1: GetSchema

		public override DatabaseSchema GetSchema(DataConnection dataConnection, GetSchemaOptions options = null)
		{
			DefaultSchema   = dataConnection.Execute<string>("SELECT CURRENT_SCHEMA FROM DUMMY");
			_databaseName   = ((DbConnection)dataConnection.Connection).Database;
			_dataSourceName = ((DbConnection) dataConnection.Connection).DataSource;            

			if (String.IsNullOrEmpty(_dataSourceName) || String.IsNullOrEmpty(_databaseName))
			{
				using (var reader = dataConnection.ExecuteReader(@"
					SELECT
						HOST,
						KEY,
						VALUE
					FROM M_HOST_INFORMATION
					WHERE KEY = 'sid'"))
				{
					if (reader.Reader.Read())
					{
						_dataSourceName = reader.Reader.GetString(0);
						_databaseName   = reader.Reader.GetString(2);
					}
				}
			}

			return base.GetSchema(dataConnection, options);
		}
开发者ID:ronnyek,项目名称:linq2db,代码行数:26,代码来源:SapHanaOdbcSchemaProvider.cs

示例2: GetTables

		protected override List<TableInfo> GetTables(DataConnection dataConnection)
		{
			CurrenSchema = dataConnection.Execute<string>("select current_schema from sysibm.sysdummy1");

			var tables = ((DbConnection)dataConnection.Connection).GetSchema("Tables");

			return
			(
				from t in tables.AsEnumerable()
				where
					new[] { "TABLE", "VIEW" }.Contains(t.Field<string>("TABLE_TYPE"))
				let catalog = dataConnection.Connection.Database
				let schema  = t.Field<string>("TABLE_SCHEMA")
				let name    = t.Field<string>("TABLE_NAME")
				where IncludedSchemas.Length != 0 || ExcludedSchemas.Length != 0 || schema == CurrenSchema
				select new TableInfo
				{
					TableID         = catalog + '.' + schema + '.' + name,
					CatalogName     = catalog,
					SchemaName      = schema,
					TableName       = name,
					IsDefaultSchema = schema.IsNullOrEmpty(),
					IsView          = t.Field<string>("TABLE_TYPE") == "VIEW",
					Description     = t.Field<string>("REMARKS"),
				}
			).ToList();
		}
开发者ID:donners77,项目名称:linq2db,代码行数:27,代码来源:DB2LUWSchemaProvider.cs

示例3: GetSchema

		public override DatabaseSchema GetSchema(DataConnection dataConnection, GetSchemaOptions options = null)
		{
			HanaSchemaOptions = options as GetHanaSchemaOptions;
			DefaultSchema = dataConnection.Execute<string>("SELECT CURRENT_SCHEMA FROM DUMMY");
			HaveAccessForCalculationViews = CheckAccessForCalculationViews(dataConnection);
			return base.GetSchema(dataConnection, options);
		}
开发者ID:donners77,项目名称:linq2db,代码行数:7,代码来源:SapHanaSchemaProvider.cs

示例4: GetTables

		protected override List<TableInfo> GetTables(DataConnection dataConnection)
		{
			_currentUser = dataConnection.Execute<string>("select user from dual");

			if (IncludedSchemas.Length != 0 || ExcludedSchemas.Length != 0)
			{
				// This is very slow
				return dataConnection.Query<TableInfo>(
					@"
					SELECT
						d.OWNER || '.' || d.NAME                         as TableID,
						d.OWNER                                          as SchemaName,
						d.NAME                                           as TableName,
						d.IsView                                         as IsView,
						CASE :CurrentUser WHEN d.OWNER THEN 1 ELSE 0 END as IsDefaultSchema,
						tc.COMMENTS                                      as Description
					FROM
					(
						SELECT t.OWNER, t.TABLE_NAME NAME, 0 as IsView FROM ALL_TABLES t
							UNION ALL
							SELECT v.OWNER, v.VIEW_NAME NAME, 1 as IsView FROM ALL_VIEWS v
					) d
						JOIN ALL_TAB_COMMENTS tc ON
							d.OWNER = tc.OWNER AND
							d.NAME  = tc.TABLE_NAME
					ORDER BY TableID, isView
					",
					new { CurrentUser = _currentUser })
				.ToList();
			}
			else
			{
				// This is significally faster
				return dataConnection.Query<TableInfo>(
					@"
					SELECT
						:CurrentUser || '.' || d.NAME as TableID,
						:CurrentUser                  as SchemaName,
						d.NAME                        as TableName,
						d.IsView                      as IsView,
						1                             as IsDefaultSchema,
						tc.COMMENTS                   as Description
					FROM
					(
						SELECT t.TABLE_NAME NAME, 0 as IsView FROM USER_TABLES t
							UNION ALL
							SELECT v.VIEW_NAME NAME, 1 as IsView FROM USER_VIEWS v
					) d
						JOIN USER_TAB_COMMENTS tc ON
							d.NAME = tc.TABLE_NAME
					ORDER BY TableID, isView
					",
					new { CurrentUser = _currentUser })
				.ToList();
			}
		}
开发者ID:ronnyek,项目名称:linq2db,代码行数:56,代码来源:OracleSchemaProvider.cs

示例5: CheckAccessForCalculationViews

		private bool CheckAccessForCalculationViews(DataConnection dataConnection)
		{
			try
			{
				dataConnection.Execute("SELECT 1 FROM _SYS_BI.BIMC_ALL_CUBES LIMIT 1");
				return true;
			}
			catch (Exception)
			{
				var options = HanaSchemaOptions ?? new GetHanaSchemaOptions();
				if (options.ThrowExceptionIfCalculationViewsNotAuthorized)
				{
					throw;
				}
			}

			return false;
		}
开发者ID:donners77,项目名称:linq2db,代码行数:18,代码来源:SapHanaSchemaProvider.cs

示例6: GetTables

		protected override List<TableInfo> GetTables(DataConnection dataConnection)
		{
			_currentUser = dataConnection.Execute<string>("select user from dual");

			var tables = ((DbConnection)dataConnection.Connection).GetSchema("Tables");
			var views  = ((DbConnection)dataConnection.Connection).GetSchema("Views");

			return
			(
				from t in tables.AsEnumerable()
				let schema  = t.Field<string>("OWNER")
				let name    = t.Field<string>("TABLE_NAME")
				where IncludedSchemas.Length != 0 || ExcludedSchemas.Length != 0 || schema == _currentUser
				select new TableInfo
				{
					TableID         = schema + '.' + name,
					SchemaName      = schema,
					TableName       = name,
					IsDefaultSchema = schema == _currentUser,
					IsView          = false
				}
			).Concat
			(
				from t in views.AsEnumerable()
				let schema  = t.Field<string>("OWNER")
				let name    = t.Field<string>("VIEW_NAME")
				where IncludedSchemas.Length != 0 || ExcludedSchemas.Length != 0 || schema == _currentUser
				select new TableInfo
				{
					TableID         = schema + '.' + name,
					SchemaName      = schema,
					TableName       = name,
					IsDefaultSchema = schema == _currentUser,
					IsView          = true
				}
			).ToList();
		}
开发者ID:donners77,项目名称:linq2db,代码行数:37,代码来源:OracleSchemaProvider.cs

示例7: InitProvider

        protected override void InitProvider(DataConnection dataConnection)
        {
            var version = dataConnection.Execute<string>("select @@version");

            _isAzure = version.IndexOf("Azure", StringComparison.Ordinal) >= 0;
        }
开发者ID:ru-sh,项目名称:linq2db,代码行数:6,代码来源:SqlServerSchemaProvider.cs


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