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


C# IDbConnection.ExecuteScalarSql方法代码示例

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


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

示例1: CanModify

		public override bool CanModify(SchemaInstaller.InstallContext context, IDbConnection connection)
		{
			// we can drop a function as long as there are no schemes using it
			return connection.ExecuteScalarSql<int>(
				"SELECT COUNT(*) FROM sys.partition_functions p JOIN sys.partition_schemes s ON (p.function_id = s.function_id) WHERE p.name = @Name", 
				new Dictionary<string, object>() { { "Name", Name.Object } }) == 0;
		}
开发者ID:henkosch,项目名称:Insight.Database.Schema,代码行数:7,代码来源:PartitionFunction.cs

示例2: Exists

		public override bool Exists(IDbConnection connection)
		{
			return 0 < connection.ExecuteScalarSql<int>(String.Format(@"
					SELECT COUNT (*)
						FROM sys.database_principals WHERE name = '{0}' AND type = 'R'",
				Name.Object));
		}
开发者ID:henkosch,项目名称:Insight.Database.Schema,代码行数:7,代码来源:Role.cs

示例3: CanModify

		public override bool CanModify(SchemaInstaller.InstallContext context, IDbConnection connection)
		{
			// we can drop a udt unless it is used in a table
			return connection.ExecuteScalarSql<int>(
				"SELECT COUNT(*) FROM sys.types t JOIN sys.columns c ON (t.user_type_id = c.user_type_id) WHERE t.Name = @Name",
				new Dictionary<string, object>() { { "Name", Name.Object } }) == 0;
		}
开发者ID:henkosch,项目名称:Insight.Database.Schema,代码行数:7,代码来源:UserDefinedType.cs

示例4: Exists

		public override bool Exists(IDbConnection connection)
		{
			return 0 < connection.ExecuteScalarSql<int>(String.Format(@"
					SELECT COUNT (*)
						FROM sys.conversation_priorities
						WHERE name = '{0}'",
				Name.Object));
		}
开发者ID:henkosch,项目名称:Insight.Database.Schema,代码行数:8,代码来源:BrokerPriority.cs

示例5: Exists

		public override bool Exists(IDbConnection connection)
		{
			return 0 < connection.ExecuteScalarSql<int>(String.Format(@"
					SELECT COUNT (*)
						FROM sys.service_queues
						WHERE object_id = OBJECT_ID('{0}')",
				Name.SchemaQualifiedObject));
		}
开发者ID:henkosch,项目名称:Insight.Database.Schema,代码行数:8,代码来源:Queue.cs

示例6: Exists

		public override bool Exists(IDbConnection connection)
		{
			return 0 < connection.ExecuteScalarSql<int>(String.Format(@"
					SELECT COUNT (*)
						FROM sys.service_message_types
						WHERE name = '{0}'",
				Name.Object));
		}
开发者ID:henkosch,项目名称:Insight.Database.Schema,代码行数:8,代码来源:MessageType.cs

示例7: CanDrop

		public override bool CanDrop(SchemaInstaller.InstallContext context, IDbConnection connection)
		{
			return 0 == connection.ExecuteScalarSql<int>(String.Format(@"
				SELECT COUNT(*)
				FROM sys.service_queues q
				JOIN sys.service_queue_usages u ON (q.object_id = u.service_queue_id)
				WHERE q.object_id = OBJECT_ID('{0}')",
				Name.SchemaQualifiedObject));
		}
开发者ID:henkosch,项目名称:Insight.Database.Schema,代码行数:9,代码来源:Queue.cs

示例8: CanDrop

		public override bool CanDrop(SchemaInstaller.InstallContext context, IDbConnection connection)
		{
			return 0 == connection.ExecuteScalarSql<int>(String.Format(@"
				SELECT COUNT(*)
				FROM sys.service_contract_message_usages c
				JOIN sys.service_message_types m ON (c.message_type_id = m.message_type_id)
				WHERE m.name = '{0}'",
				Name.Object));
		}
开发者ID:henkosch,项目名称:Insight.Database.Schema,代码行数:9,代码来源:MessageType.cs

示例9: Exists

		public override bool Exists(IDbConnection connection)
		{
			return 0 < connection.ExecuteScalarSql<int>(String.Format(@"
					SELECT COUNT (*)
						FROM sys.objects o
						JOIN sys.schemas s ON (o.schema_id = s.schema_id)
						WHERE s.name = '{0}' AND o.name = '{1}'",
				Name.Schema,
				Name.Object));
		}
开发者ID:henkosch,项目名称:Insight.Database.Schema,代码行数:10,代码来源:Function.cs

示例10: CanModify

		public override bool CanModify(SchemaInstaller.InstallContext context, IDbConnection connection)
		{
			// we can drop a scheme as long as there are no tables using it
			return connection.ExecuteScalarSql<int>(@"SELECT COUNT(*) FROM sys.partition_schemes s 
				WHERE s.name = @Name AND (
					s.data_space_id IN (SELECT data_space_id FROM sys.indexes) OR 
					s.data_space_id IN (SELECT lob_data_space_id FROM sys.tables) OR
					s.data_space_id IN (SELECT filestream_data_space_id FROM sys.tables))
				", new Dictionary<string, object>() { { "Name", Name.Object } }) == 0;
		}
开发者ID:henkosch,项目名称:Insight.Database.Schema,代码行数:10,代码来源:PartitionScheme.cs

示例11: Exists

		public override bool Exists(IDbConnection connection)
		{
			return 0 < connection.ExecuteScalarSql<int>(String.Format(@"SELECT COUNT(*)
						FROM sys.indexes i
						JOIN sys.objects t ON (i.object_id = t.object_id)
						JOIN sys.schemas s ON (t.schema_id = s.schema_id)
						WHERE s.Name = '{0}' AND t.name = '{1}' AND i.name = '{2}'",
				Name.Schema,
				Name.Table,
				Name.Object));
		}
开发者ID:henkosch,项目名称:Insight.Database.Schema,代码行数:11,代码来源:Index.cs

示例12: Exists

		public override bool Exists(IDbConnection connection)
		{
			return 0 < connection.ExecuteScalarSql<int>(String.Format(@"SELECT COUNT(*)
						FROM sys.default_constraints d
						JOIN sys.schemas s ON (d.schema_id = s.schema_id)
						JOIN sys.objects o ON (d.parent_object_id = o.object_id)
						JOIN sys.columns c ON (c.object_id = o.object_id AND c.column_id = d.parent_column_id)
						WHERE s.Name = '{0}' AND o.name = '{1}' AND c.name = '{2}'",
				Name.Schema,
				Name.Table,
				Name.Object));
		}
开发者ID:henkosch,项目名称:Insight.Database.Schema,代码行数:12,代码来源:Default.cs

示例13: CanDrop

		public override bool CanDrop(SchemaInstaller.InstallContext context, IDbConnection connection)
		{
			// azure can't drop the clustered index, so we have to warn if we are attempting to modify that
			if (context.IsAzure)
			{
				if (Sql.IndexOf("NONCLUSTERED", StringComparison.OrdinalIgnoreCase) == -1 && Sql.IndexOf("CLUSTERED", StringComparison.OrdinalIgnoreCase) != -1)
					return false;
			}

			return 0 == connection.ExecuteScalarSql<int>(String.Format(@"SELECT COUNT(*)
						FROM sys.xml_indexes i
						WHERE i.object_id = OBJECT_ID('{0}')",
				Name.SchemaQualifiedTable));
		}
开发者ID:henkosch,项目名称:Insight.Database.Schema,代码行数:14,代码来源:PrimaryKey.cs

示例14: CanDrop

		public override bool CanDrop(SchemaInstaller.InstallContext context, IDbConnection connection)
		{
			return 0 == connection.ExecuteScalarSql<int>(String.Format("SELECT COUNT(*) FROM sys.objects o WHERE o.schema_id = SCHEMA_ID('{0}')", Name.Object));
		}
开发者ID:henkosch,项目名称:Insight.Database.Schema,代码行数:4,代码来源:Schema.cs


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